-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Labels
questionQuestion on NSubstitute behaviourQuestion on NSubstitute behaviour
Description
Question
Hello everyone. I'm having trouble in verifying a call to a method accepting a single argument, whose type is a generic interface (say, IMyArgument<T>
). At compile time, I don't have access to the concrete type of the argument being passed, so I tried Arg.Any<IMyArgument<Arg.AnyType>>()
, but that fails.
IMyService service = Substitute.For<IMyService>();
var argument = new MyStringArgument();
service.MyMethod(argument);
// The following line throws. Using ReceivedWithAnyArgs didn't help.
service.Received().MyMethod(Arg.Any<IMyArgument<Arg.AnyType>>());
public interface IMyService
{
void MyMethod<T>(IMyArgument<T> argument);
}
public interface IMyArgument<T> { }
// Suppose I don't have access to this type at compile time, so I could not have written Arg.Any<MyStringArgument>()
public class MyStringArgument : IMyArgument<string> { }
I couldn't find any information addressing this specific issue in the documentation. Any suggestion is appreciated :)
rpallares
Metadata
Metadata
Assignees
Labels
questionQuestion on NSubstitute behaviourQuestion on NSubstitute behaviour