views:

39

answers:

2

I'm having another fun problem with Rhino Mocks. Can anyone answer this one:

Here's the call that I'm making in my code:

Expect.On(this.mockDal).Call(this.mockDal.SaveObject(entry)).IgnoreArguments();

mockDal is mocking something of type Dal, and it's SaveObject method's signature is this;

void SaveObject(object obj);

Visual Studio, on the first part of my code (i.e. not the part with IgnoreArguments) is giving me this wonderfully confusing error:

Error 1 The type arguments for method 'Rhino.Mocks.Interfaces.ICreateMethodExpectation.Call<T>(T)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I've tried this with entry being of type var and its actual type (called SpaceViewEntry), and it gives me the same error each time. Any ideas?

A: 

Have you try this

Expect.On(this.mockDal).Call(this.mockDal.SaveObject((object)entry)).IgnoreArguments();
alejandrobog
Still throws the error
IronMan84
+1  A: 

If you just want to set up an expectation that the SaveObject will be called, using the new AAA syntax might be easier:

this.mockDal.Expect(m => m.SaveObject(entry)).IgnoreArguments();
Patrick Steele
That worked! Why did that one work over the other way?
IronMan84
Not sure. I learned Rhino.Mocks using the AAA syntax (and the extension methods). I don't really know how they translate to the Expect.* and Stub.* method calls.
Patrick Steele