This is more a question rather than a bug report. Inspired by a question on SO
Suppose we have an interface with a generic method:
public interface IInterfaceWithGenericMethod
{
int GenericMethod<T>(T arg);
}
Then when we specify the sub to return a value for any argument then it fails on the call with another generic type.
var sub = Substitute.For<IInterfaceWithGenericMethod>();
const int expectedInt = 1;
sub.GenericMethod(Arg.Any<int>()).ReturnsForAnyArgs(expectedInt); // Specifying for int
Assert.AreEqual(expectedInt, sub.GenericMethod(0)); // Works for int
Assert.AreEqual(expectedInt, sub.GenericMethod("")); // Fails for string
The same is right for WhenForAnyArgs().
Imo this isn't obvious behavior. Thoughts?
This is more a question rather than a bug report. Inspired by a question on SO
Suppose we have an interface with a generic method:
Then when we specify the sub to return a value for any argument then it fails on the call with another generic type.
The same is right for
WhenForAnyArgs().Imo this isn't obvious behavior. Thoughts?