You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We cannot upgrade to newer versions due to some incompatibility issue with Castle dependency. Please document how to match generic arguments prior to v4.13. Whether it is even possible to do something equivalent to
public interface IFoo
{
bool M1<T>();
bool M2<T>(T arg);
}
var mock = new Mock<IFoo>();
// matches any type argument:
mock.Setup(m => m.M1<It.IsAnyType>()).Returns(true);
The text was updated successfully, but these errors were encountered:
Feel free to help out... this is an open-source project, not a free support service. 😉
That being said, back to your actual question: Note that It.IsAnyType is not actually needed in a many simple cases. Often, you can just use object as a type argument when setting up a method; since all values in .NET are convertible to object, that might suffice to match anything.
It.IsAnyType or other type matchers only need to be used where object doesn't work (off the top of my head, e.g. when a generic type parameter constraint disallows object, or with nested types where co-/contravariance might get in the way).
I did make a few minor changes, most notably moving the object part before the It.IsAnyType part, first because it will work for older Moq versions, too, and more importantly, because it's the simpler & better performing solution and should be tried first.
We cannot upgrade to newer versions due to some incompatibility issue with Castle dependency. Please document how to match generic arguments prior to v4.13. Whether it is even possible to do something equivalent to
The text was updated successfully, but these errors were encountered: