-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Moq should not use a mock's internal implementation of IEnumerable #478
Comments
@stakx Ouch. Just got to open the project on VS2017. I wanted to see what tests were done on Turns out two thirds of the tests fail then. I guess I'll have a worst time than anticipated XD |
@Eregrith: Yes :-D It is an important component. Apart from its use for diagnostic messages, Moq uses string representations of setup expressions to quickly look up setups ( As long as you can make sure that the string representation of a setup expression properly captures a method call's "shape", you're good. Perhaps the easiest thing would be to change / augment those tests to see if As per our previous discussion, I'll assign you to this issue for now. If you don't find a good way to untangle Moq from its |
@stakx Thanks ! I'll have to do some speleology to see if I can find tests targetting |
Given (P.S.: You're of course welcome to add proper unit tests for that component, if you don't find any.) |
@Eregrith - quick ping. Are you still looking into this at all, or would you rather hand this back? I've just been playing around a bit with this: You could indeed get things (including your originally reported issue) working properly simply by replacing the highlighted second condition with: && !(value is IMocked) |
@stakx Sorry I'm not currently in a schedule allowing me to look into this :/ If you're able to handle it, I'll gladly let you have at it :) |
@Eregrith: No worries, I can make the necessary change. |
( See #464 )
https://github.com/moq/moq4/blob/61c35056dda76a157dd78cd9578cee86f7a16f02/Source/Extensions.cs#L91-L100
This part calls for the checked value's implementation of
GetEnumerator()
. If and when that value is a mock, callingGetEnumerator()
might do anything, as far as throwing an exception.Moq should not call for that value's implementation of
IEnumerable
, or even any method on that value for that matter.The text was updated successfully, but these errors were encountered: