Rhino Mocks——断言不与模拟/存根交互
是否可以看出模拟/存根在 RhinoMocks 中根本没有看到任何交互。 大致如下:
logger.AssertNoInteraction();
这将断言在存根记录器上没有调用任何方法。
这比每次调用以下命令要简单得多:
logger.AssertWasNotCalled(l => l.Debug(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Info(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Warning(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Error(Arg<string>.Is.Anything()));
Is it possible to tell that a mock/stub has seen no interaction at all in RhinoMocks.
Something along the lines of:
logger.AssertNoInteraction();
Which would assert no method has been called on the stubbed logger.
This would be a much less tedious than calling the following each time:
logger.AssertWasNotCalled(l => l.Debug(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Info(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Warning(Arg<string>.Is.Anything()));
logger.AssertWasNotCalled(l => l.Error(Arg<string>.Is.Anything()));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用严格的模拟并且没有设置期望,则在调用模拟时您将收到异常。
If you use a strict mock and you do not set up an expectation you will get an exception if a call was made to the mock.