Closed 4imble closed 7 years ago
This is a limitation with NSubstitute's syntax. When Received()
is called it doesn't actually know what call is going to come next. If it never intercepts a call (i.e. a non-virtual is called) then it won't know something is wrong. (There is a bit more on how NSub works on this post by Jake, starting at the section "NSubstitute Tradeoffs".)
I'll leave this issue open as I can have a look at improving the detection of these cases. Unfortunately it can result in things like other tests failing, but it might be better than nothing.
Closing until we get a proposal for working around this. I think it is a limitation of NSub's syntax.
Both the assertions below pass when .Execute is not virtual. This was confusing me for a while. I ended up swapping out NS for Moq and Moq reported an error informing me of the problem. It would be nice if NS did this too to save confusion.
//Using MSpec
public class When_told_to_execute_all_it_should_execute_all_commands : WithSubject
{
static AddTaskCommand command1;
static AddTaskCommand command2;
http://stackoverflow.com/questions/26711633/how-to-assert-method-called-in-mspec-with-nsubstitute/26712964#26712964
Just tried FakeItEasy too, which is also reporting a nice error message when the method is not virtual.