I use NUnit and NSubstitute for unit testing. I have the following:
public interface IDataProvider
{
void Log(int tvmId, DateTime time, int source, int level, int eventCode, string message);
}
...
var fakeDataProvider = Substitute.For<IDataProvider>();
...
fakeDataProvider.Received().Log(
Arg.Any<int>(),
new DateTime(2000, 1, 1),
0,
0,
0,
null);
fakeDataProvider.Received() throws AmbiguousArgumentException with the message that it cannot determine argument specifications to use. I have found the following on SO
Cannot determine argument specifications to use
which is related but I cannot apply it in the code above. Why is the above code ambiguous? How else could I specify to Received() that it should accept any argument?
Since you have several int
parameters in the Log
method, you have to use the argument specification for each and every one of them.
fakeDataProvider.Received().Log(
Arg.Any<int>(),
new DateTime(2000, 1, 1),
Arg.Is(0),
Arg.Is(0),
Arg.Is(0),
null);