Watch where you put Received when working with NSubstitute


I have a test that I know should be failing but isn’t.



Make sure you have Received in the right location. The line of code above will always pass no matter if the call was made or not. To correct this move Received before CreateDirectory.

Now the tests evaluates the condition correctly. It would be nice if when Received is last you got a warning or compiler error. But because if the fluent nature of the API and extension methods that code is valid written either way.

Add comment