Rhino Mocks - Fluent Mocking - Expect.Call question

Posted by Ben Cawley on Stack Overflow See other posts from Stack Overflow or by Ben Cawley
Published on 2010-05-17T08:14:20Z Indexed on 2010/05/17 8:20 UTC
Read the original article Hit count: 388

Filed under:
|

Hi,

I'm trying to use the fluent mocking style of Rhino.Mocks and have the following code that works on a mock IDictionary object called 'factories':

With.Mocks(_Repository).Expecting(() =>
        {
            Expect.Call(() => factories.ContainsKey(Arg<String>.Is.Anything));
            LastCall.Return(false);

            Expect.Call(() => factories.Add(Arg<String>.Is.Anything, Arg<Object>.Is.Anything));
        }).Verify(() =>
        {
            _Service = new ObjectRequestService(factories);
            _Service.RegisterObjectFactory(Valid_Factory_Key, factory);
        });

Now, the only way I have been able to set the return value of the ContainsKey call is to use LastCall.Return(true) on the following line.

I'm sure I'm mixing styles here as Expect.Call() has a .Return(Expect.Action) method but I can't figure out how I am suppose to use it correctly to return a boolean value?

Can anyone help out? Hope the question is clear enough - let me know if anyone needs more info!

Cheers, Ben

© Stack Overflow or respective owner

Related posts about c#

Related posts about rhino-mocks