Skip to content
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

Make abstract events defined in classes work even when CallBase is true #395

Merged
merged 2 commits into from
Jun 27, 2017

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Jun 27, 2017

Moq does not currently mock an abstract event defined in a class correctly when a mock's CallBase is set to true. It will try to invoke the base event accessors (which are defined abstract in this case), which leads to DynamicProxy triggering a NotImplementedException.

This PR corrects that bug by suppressing the call to InvokeBase for event attach / detach accessors when the base accessor methods are abstract. (Up until now, such a check was in place only for events defined in interfaces.)

This fixes #296.

This test shows how it is currently impossible to subscribe an event
handler (and then raise the event) if the event is abstract, defined
in an abstract class, and `CallBase` is set to true.
`InvokeBase()` should not just be suppressed for events defined in
interfaces, but also for abstract events. The latter category in fact
includes the former, so that's all we really need to check for.
@stakx stakx merged commit b23886d into devlooped:develop Jun 27, 2017
@stakx stakx deleted the abstract-event branch June 27, 2017 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant