This error means that you are trying to fake a method that is not declared as virtual.
Moq generates a type at runtime in order to be able to fake it; the generated type inherits from the original type and overrides its virtual methods. Since non-virtual methods cannot be overridden (this is a language specification, this is not a limitation of Moq), it is impossible to fake these methods.
As a solution, you can wrap a class that raises an event that dispatches MouseButtonEventArgs and passes in its own class, which declares the corresponding methods as virtual. I think this may be a problem in your case, but worth a try.
Another solution might be to use an isolation environment that allows you to fake non-virtual methods. Typemock Isolator, for example, is the foundation that can do this. The isolator uses a different mechanism, so it allows you to fake such methods.
Disclaimer - I work on Typemock
source share