-
-
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
Question about order of Setup #831
Comments
That's generally a good rule of thumb to follow. Later setups always take preference over earlier ones, and that is definitely the intended behavior of Moq (even if it isn't explicitly documented). |
Thank you. In the quickstart guide this is the example for this:
Is it possible to introduce something similar to how Rhino Mocks does this, so I don't have to declare a local variable? In Rhino I can do:
There is no need to declare a local variable, can pass in constants, or conditional expressions (ternary etc), I don't get ReSharper warnings about the local variable. I tested this in Moq and it worked for me with the following class (naming is not the best):
Moq works with this as well:
I would be happy to see this as part of Moq if you don't see an issue with it. Right now I have to implement a shared testing utils project to share amongst my tests if I want something similar. Opinion? |
I don't see the response here, although I did receive an e-mail notification:
I don't think that solves what I was asking.
|
The reason you don't see that response here (anymore) is because I deleted it. If I had read your second post more carefully before posting it, I wouldn't have posted it in the first place as it's clear that you're definitely not looking for C# discards. 😆 However it seems I somehow forgot to post a revised reply; my apologies for that mistake.
Regarding your suggested feature, I don't think this needs to go into Moq. The fact that Moq actually reads an |
I have a question about the significance of the order of the
Setup
statements.I was converting a large amount of tests (~3000) from Rhino Mocks to Moq and some of my tests were failing because of the following behavior.
This indicates that the order of the setups matter and generally it should be least specific to most specific. I didn't really find documentation about this (maybe wasn't looking too hard), but can you confirm wether this is intended behavior?
For some reason I thought that finding the best match is done by the library and not affected by the order (only if you're overriding a previous
Setup
).The text was updated successfully, but these errors were encountered: