I have a mock and have set up a call to DoInstead on it, something like this: -
Later on in my test, I call an Assert on that same method: -
When it hits the Assert line, my DoInstead handler suddenly gets fired. It's as if the Assertion is actually called the mock method like my production code has. Even worse, if I put a Match on the Arrange call e.g.
but this is completely ignored and it still falls into the Console.WriteLine call.
At any rate, calls to Assert should not implicitly call DoInstead handlers that have already been set up.
Mock.Arrange(() => myService.Foo(Arg.AnyGuid))
.DoInstead(
new
System.Action<System.Guid>(Console.WriteLine));
Later on in my test, I call an Assert on that same method: -
Mock.Assert(() => myService.Foo(Arg.AnyGuid), Occurs.Once());
When it hits the Assert line, my DoInstead handler suddenly gets fired. It's as if the Assertion is actually called the mock method like my production code has. Even worse, if I put a Match on the Arrange call e.g.
myService.Foo(Arg.Matches<Guid>(g => g != Guid.Empty))
but this is completely ignored and it still falls into the Console.WriteLine call.
At any rate, calls to Assert should not implicitly call DoInstead handlers that have already been set up.