Callback arguments didn't match the method arguments
One of those, "it sounds obvious but I can't work it out" errors. This one in Rhino mocks, made more confusing by profuse use of generics, anonymous types and lambda stuff.
I had a mock expectation that was set up like this:
_DataService.Mock.Expect(r => r.UpdateData(Arg.Is.Equal(Id), Arg
.Is.Anything))
.Callback((Guid c,Summary m) => // etc
which caused the above error during the mock setup. I tried lots of various implicit and explicit changes to infer arguments etc. They always built but always crashed. The reason in my case was simply that UpdateData is not a generic method (despite all the GetData methods being generic) but which takes an OBJECT as the second argument. This fact was masked by the way I was calling it with a Summary object and I couldn't understand why it fell over. The code should have been like this:
_DataService.Mock.Expect(r => r.UpdateData(Arg.Is.Equal(Id), Arg
.Is.Anything))
.Callback((Guid c,object m) => // etc
Which I could then cast to the correct type inside my callback.
I had a mock expectation that was set up like this:
_DataService.Mock.Expect(r => r.UpdateData(Arg
.Callback((Guid c,Summary m) => // etc
which caused the above error during the mock setup. I tried lots of various implicit and explicit changes to infer arguments etc. They always built but always crashed. The reason in my case was simply that UpdateData is not a generic method (despite all the GetData methods being generic) but which takes an OBJECT as the second argument. This fact was masked by the way I was calling it with a Summary object and I couldn't understand why it fell over. The code should have been like this:
_DataService.Mock.Expect(r => r.UpdateData(Arg
.Callback((Guid c,object m) => // etc
Which I could then cast to the correct type inside my callback.