You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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?
The text was updated successfully, but these errors were encountered: