Rhino Mocks - Fluent Mocking - Expect.Call question
- by Ben Cawley
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