开发者

Rhino Mocks - Fluent Mocking - Expect.Call question

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(() =>
        {
         开发者_如何学Go   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


I believe the following line will give you want you want:

Expect.Call(factories.ContainsKey(Arg<string>.Is.Anything)).Return(false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜