-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Way to Exclude Calls from VerifyNoOtherCalls #1490
Comments
As side note, the most obvious way to implement this would be to let |
Wouldn't turn your mock into a loose mock and only verify what you're interested in work better in this case? |
For situations where there aren't many methods you need to verify, sure. But the use case for this is when you have a LOT of functions, and you want to verify that most of them are never touched, with the possible exception of a few accessors. In that scenario, it's much more convenient to handle everything in bulk, using |
If most should not be called, then a strict mock with no setups for them seems like a better approach? |
Hmmmm. Fair point. Maybe this is more of a documentation issue then? It is not obvious that strict mocks are the way to handle this case, for someone with limited familiarity with the library. |
Yeah, perhaps. I guess this is something that is typically covered by the multiple blogs/stackoverflow/online curses you can find by now on using Moq itself. But I'll keep that in mind for vNext. Feel free to close this issue if you feel the strict mock will suffice. Thanks! |
When verifying calls on mocks, it often happens that there is some trivial operation (like a property read) that you really don't care about, and the executing code is allowed to invoke any number of times. However, because of the way
VerifyNoOtherCalls
works, there's no way to mark things as ignored - you have to explicitly specify each individual call, which leads to unit tests either being too tightly coupled to the main code base, or using hackish work-arounds (like doingTimes.AtMost(1000)
). There ought to be a way to tell Moq that such-and-such a call just isn't relevant.The text was updated successfully, but these errors were encountered: