Is there a way using Natural Mocks or AAA to ensure that a method is called at least once with a specific set of parameters if that method can be called more than once in the method being tested?
For example:
public class Foo
public ILogger Logger { get; set; }
public void SomeMethod() {
// I want this one to be ignored
Logger.Log("Foo");
// I want to do a substring validation on the message being logged
Logger.Log("Some message with a really long string");
// I want this one to be ignored
Logger.Log("Bar");
}
Essentially, I am only interested in the middle log statement because I want to check that the log entry has a particular substring in it. I don't want the test to be fragile, so I don't want to have to add explicit calls for the Foo and Bar log entries because if additional logging calls are made later on I don't want to have to change my unit test just to account for those...
Something like (pseudo code):
Isolate.Verify.WasCalled((string s) => logger.Log(s))
.AndArgumentsMatch(s => s.Contains("message with"));
How can you achieve this with the 5.3.4 APIs (Just noticed that 5.3.5 has this but I can't upgrade)?
Thanks in advance,
Carlos