Hi,
I'm receiving InvalidOperationException in the attached code example, using last rhino mocks.
Here is the stacktrace:
at
System.Reflection.RuntimeMethodInfo.
GetGenericMethodDefinition()
at
Rhino.Mocks.MethodRecorders.UnorderedMethodRecorder.
MethodsEquals(
MethodInfo method,
ProxyMethodExpectationTriplet triplet)
at
Rhino.Mocks.MethodRecorders.UnorderedMethodRecorder.
GetAllExpectationsForProxyAndMethod(
Object proxy,
MethodInfo method)
at
Rhino.Mocks.MethodRecorders.UnorderedMethodRecorder.CalcExpectedAndActual.
Calculate(
Object proxy,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.MethodRecorders.UnorderedMethodRecorder.
UnexpectedMethodCall(
IInvocation invocation,
Object proxy,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.MethodRecorders.UnorderedMethodRecorder.
DoGetRecordedExpectation(
IInvocation invocation,
Object proxy,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.MethodRecorders.MethodRecorderBase.
GetRecordedExpectation(
IInvocation invocation,
Object proxy,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.Impl.ReplayMockState.
DoMethodCall(
IInvocation invocation,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.Impl.ReplayMockState.
MethodCall(
IInvocation invocation,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.MockRepository.
MethodCall(
IInvocation invocation,
Object proxy,
MethodInfo method,
Object[]
args)
at
Rhino.Mocks.Impl.Invocation.Actions.RegularInvocation.
PerformAgainst(
IInvocation invocation)
at
Rhino.Mocks.Impl.RhinoInterceptor.
Intercept(
IInvocation invocation)
at
Castle.DynamicProxy.AbstractInvocation.
Proceed()
at
Castle.Proxies.IDbHandlerProxy6d12ffc56cb147579f1dff408afd8d46.IDbHandler.OpenUoW<
T>()
at
ConsoleApplication1.UnitTest.
MethodName() in
UnitTest.cs: line 28
I know that my expectations are not actually right - I set an expectation onto non-generic method, but call generic method. Though I would expect to receive more meaningful exception from Rhino.Mock
I've caught this while debugging my test for the real application, and spent a lot of time debugging Rhino.Mocks while I figured out the error.
It looks like the method in Rhino.Mocks:
UnorderedMethodRecorder.
MethodsEquals(
MethodInfo method,
ProxyMethodExpectationTriplet triplet)
has this code:
if(method.IsGenericMethod==false)
return triplet.Method == method;
return triplet.Method.GetGenericMethodDefinition() == method.GetGenericMethodDefinition();
which actually does not count a situation when method is generic, but triplet.Method is not - this is exactly my situation. Call to triplet.Method.GetGenericMethodDefinition() fails because of that.
There should be one additional check, like this:
if (method.IsGenericMethod != triplet.Method.IsGenericMethod)
return false;
If I am right, and there is no catch, where should I report this or make a pull request? Looks like https://github.com/ayende/rhino-mocks is abandoned.