Assume I have some interface with a generic method and no parameters:
public interface Interface {
void Method<T>();
}
Now I wish to implement the mock for this class (I'm using Moq
) and I wish to mock this method for some concrete type - let's say I'm mocking Method<String>()
calls.
mock = new Mock<Interface>();
mock.Setup(x => x.Method ????).Returns(String("abc"));
The idea of ????
should be clear - this lambda expression should handle the case when T
in the Method<T>
is actually a String
.
Is there any way I can achieve the wanted behavior?