How do you Setup a generic returntype in Moq?
I have the following interface:
public interface IFoo
{
T Bar<T>();
}
Now I want to setup Bar<T>() to work inside a test
var foo = new Mock<IFoo>();
foo.Setup(x => x.Bar<It.IsAnyType>()).Returns(new Mock<???>().Object);
How do I fill out ???, or if that is not possible, then how do I return a generic mock?
There are 100s of types, I am trying to avoid mocking them all. The test breaks (because the code throws and exception) if the call returns null for any type, which is sadly the default non-mocked behavior.