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
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.
IMyServiceservice= Substitute.For<IMyService>();varargument=new MyStringArgument();
service.MyMethod(argument);// The following line throws. Using ReceivedWithAnyArgs didn't help.
service.Received().MyMethod(Arg.Any<IMyArgument<Arg.AnyType>>());publicinterfaceIMyService{voidMyMethod<T>(IMyArgument<T>argument);}publicinterfaceIMyArgument<T>{}// Suppose I don't have access to this type at compile time, so I could not have written Arg.Any<MyStringArgument>()publicclassMyStringArgument:IMyArgument<string>{}
I couldn't find any information addressing this specific issue in the documentation. Any suggestion is appreciated :)
The text was updated successfully, but these errors were encountered:
… type is not known (#786) (#814)
Unable to match arguments whose type is generic, when their concrete type is not known (#786)
Co-authored-by: Mihnea Rădulescu <>
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 triedArg.Any<IMyArgument<Arg.AnyType>>()
, but that fails.I couldn't find any information addressing this specific issue in the documentation. Any suggestion is appreciated :)
The text was updated successfully, but these errors were encountered: