Rhino Mocks - 流畅的模拟 - Expect.Call 问题
我正在尝试使用 Rhino.Mocks 的流畅模拟风格,并使用以下代码来处理名为“factories”的模拟 IDictionary 对象:
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);
});
现在,我能够设置 ContainsKey 调用的返回值的唯一方法是在下面的行中使用 LastCall.Return(true) 。
我确信我在这里混合了样式,因为 Expect.Call() 有一个 .Return(Expect.Action) 方法,但我不知道如何正确使用它来返回布尔值?
有人可以帮忙吗?希望问题足够清楚 - 如果有人需要更多信息,请告诉我!
干杯, 本
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信下面这行会给你想要的:
I believe the following line will give you want you want: