I'm trying to mock MouseButtonEventArgs.GetPosition()
with Moq, but I keep receiving this error:
System.ArgumentException: Invalid setup on a non-overridable member: m => m.GetPosition(It.IsAny<IInputElement>()) at Moq.Mock.ThrowIfCantOverride(Expression setup, MethodInfo methodInfo) at Moq.Mock.<>c__DisplayClass12`2.<Setup>b__11() at Moq.PexProtector.Invoke<T>(Func`1 function) at Moq.Mock.Setup<T1,TResult>(Mock mock, Expression`1 expression) at Moq.Mock`1.Setup<TResult>(Expression`1 expression)
Here is the code where I setup my mock:
var mockMbEventArgs = new Mock<MouseButtonEventArgs>();
mockMbEventArgs.Setup(m => m.GetPosition(It.IsAny<IInputElement>())).Returns(new Point(10.0, 10.0));
I'm not sure what I'm doing wrong, does anyone have any suggestions for how to do this?