-
-
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
Using 'Verify' and 'It.Is<>' with a method call inside cases the same verify the run for all invocations #1394
Comments
Hi @AntonVasserman. I haven't run your code, but by just looking at it, I suspect the problem doesn't lie with Moq, but with your usage of (Also, if it isn't self-evident: |
@stakx No I don't think this is related.
And this is the value I get: |
You have two invocations, so your predicate runs twice (once per invocation) per
|
This doesn't match with your code comments in the example shown:
|
Okay that now makes total sense... The issue is indeed with the Assert throwing. Thank you very much for the quick help and responses, and for clarifying the case here! |
You're welcome. Glad I could help with clearing things up. |
Hi moq folks,
So far we have been using Mock<>.Verify with It.Is<> inside and always there was a single evaluation. (meaning we only checked one of the invocation to match, which allowed us to write two Verifies over the same method, with different inputs and verify two different invocations)
Today I have noticed that isn't the case if inside the It.Is<> match Func we call another method.
In that case the Verify method actually runs a verification against all invocations of that method.
Here is a simple reproduction:
Is it a bug or by design?
If it's by design how can we properly verify the two invocations? Currently we are resulting in not using a method call which make the code a bit cumbersome.
The text was updated successfully, but these errors were encountered: