I have tests throughout the entire project that behave inconsistently when using NSubstitute: they pass or fail randomly at different locations, without any code modifications, simply by saving files. When this happens, only one random test will fail.
When test fails, a similar error is thrown:
Code:
NSubstitute.Exceptions.AmbiguousArgumentsException: Cannot determine argument specifications to use. Please use specifications for all arguments of the same type.
Method signature:
FindByUrl(String)
Method arguments (possible arg matchers are indicated with '*'):
FindByUrl(*<null>*)
Here is one example of the code:
Code:
[Fact]
public async Task Test()
{
IImageManager imageManager = Substitute.For<IImageManager>();
imageManager.FindByUrl(Arg.Any<string>())
.Returns(callInfo => new ImageMetadataModel(callInfo.Arg<string>()));
}
What could be wrong?