I have a mock setup:
_mock.Setup( x => x.Method( It.IsAny<Model>(), It.IsAny<string>(), IsAny<int>()));
and verify with:
_mock.Verify(x => x.Method( It.Is<Model>( p=> p.IsPresent && p.Search.Equals("term")), It.IsAny<string>(), It.IsAny<int>()), Times.Once());
public Results GetResults( Model model, string s, int i)
{
return _repo.Method(model, s, i);
}
During test the method is called twice. Once with Search == "rubbish" and once with Search=="term". Yet verify fails with the message it's being invoked 2 times.
I though using It.Is on the important parameter should give the correct 'Once'. Any ideas?