I want to test a function with the type signature
public static void DoSomething<T>(T something)
where T : class, IInterfaceA, IInterfaceB, new()
which uses new T()
internally.
I'm having problems creating a mock for T
. Thanks to another question, I already found a solution for mocking multiple interfaces. However, I'm unable to create a mock satisfying the new()
constraint. How do I solve this using Moq?
You have two options:
Choosing between the two depends on how hard it is to split the logic, whether the remaining code has enough "meat" in it and if you're willing to pay for a Mocking framework that can fake new
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With