-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Regression for event subscription between 4.10 and 4.11 #867
Comments
@chrisaut: Thank you for reporting this. I'll add (a slightly modified version of) your tests to the regresstion test suite.
It's somewhat an edge case, but yes, I believe this is to be expected. You are raising the event before the mocked object is created:
Note how, in your code, If you insert a While You might wonder why this worked in previous versions of Moq. This was in fact a (most probably unintended) side effect. When
|
@stakx thnx for the explanation, that makes perfect sense, and is easy to fixup in the couple of tests I ran into it while upgrading. However, I find the behavior a bit unexpected, I would expect a call to Raise to operate against a fully initialized object. Since its easy to workaround, kind of an edge case to add an event subscriber inside the ctor, and you indicated you probably don't want to change this behavior, I'm closing this issue. thnx for the help. |
Yes, what you're saying seems sensible. What I'm still trying to wrap my head around is the fact that most Moq API calls work perfectly fine without an actual mocked object—say, the I'll leave my PR open and reflect on this some more, perhaps |
The following seems to be a regression between 4.10 and 4.11 (4.12 behaves like 4.11):
Additional information, if the event subscription happens outside the mocked object, it still behaves as expected:
or if it happens in any of the object's methods:
The subscription to the event "E" seems to no longer take effect if the event is being subscripted to in the mocked object's ctor.
Is this expected? I was unable to find an issue regarding this change.
The text was updated successfully, but these errors were encountered: