I have an interface (called IRepository
) that has a method on it like this:
IEnumerable<TEntity> ExecuteStoredProcedure<TEntity>(string functionName,
params Tuple<string, object>[] parameters);
I am trying to set what that method will return when it is called via my unit test. Like this:
dataAccess = Substitute.For<IRepository>();
dataAccess.ExecuteStoredProcedure<MyCustomReturnType>(null, null)
.ReturnsForAnyArgs(MyCustomReturnList);
When I run the test I get this exception:
NSubstitute.Exceptions.CouldNotSetReturnException: Could not find a call to return from.
The message goes on to caution about trying to do this with actual classes, but that does not apply to me.
I tried changing my null
params to be something more real:
ExecuteStoredProcedure<MyCustomReturnType>("", new Tuple<string, object>[]{null})
But that did not help...
Any ideas what I am doing wrong with this substitute?
(My guess is that it has something to do with the params
keyword.)