Mocking the 'new ()' constraint with Moq

I want to test a function with a signature like

public static void DoSomething<T>(T something)
    where T : class, IInterfaceA, IInterfaceB, new()

which uses new T()internally.

I'm having trouble creating a layout for T. One more question, I already found the solution for bullying on several interfaces . However, I cannot create a layout that satisfies the constraint new(). How to solve this problem using Moq?

+4
source share
1 answer

You have two options:

  • unconstraint mocking framework. .NET Isolator, JustMock. IL- / , .
  • DoSomething .

, , "" , ,

+1

Source: https://habr.com/ru/post/1607604/


All Articles