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

Abstract event handlers are not mocked with CallBase=true - System.NotImplementedException is raised #296

Closed
spurlis opened this issue Oct 19, 2016 · 1 comment
Labels

Comments

@spurlis
Copy link

spurlis commented Oct 19, 2016

When I create a mock of an abstract class, I expect that the mock enables the usage of all abstract methods and eventhandlers. This expectation is fullfilled with CallBase = false.

However if I create the mock with CallBase = true, the call of abstract methods is still working (they are correctly mocked), however attaching to an abstract eventhandler is no longer possible and results in an exception:

System.NotImplementedException : This is a DynamicProxy2 error: The interceptor attempted to 'Proceed' for method 'Void add_SomethingChanged(System.EventHandler)' which is abstract. When calling an abstract method there is no implementation to 'proceed' to and it is the responsibility of the interceptor to mimic the implementation (set return value, out arguments etc)

Attached you can find an example test reproducing the error. If I use "CallBase = false" in this test everything works as expected.

MoqBug.txt

Are my expectations correct and this is a bug or is this intended behaviour?

@stakx
Copy link
Contributor

stakx commented Jun 27, 2017

This will be fixed in the next version (>4.7.63) of Moq.

@stakx stakx closed this as completed Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants