我可以在 Rhino-Mocks 3.6 中使用 AAA 语法测试方法调用顺序吗? [英] Can I test method call order with AAA syntax in Rhino-Mocks 3.6?

查看:26
本文介绍了我可以在 Rhino-Mocks 3.6 中使用 AAA 语法测试方法调用顺序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Rhino-mocks 3.6 中使用 AAA 语法测试 Method1 调用 1st,然后 Method2 调用,然后 Method3 的情况?

Is it possible to test for the following example if the Method1 called 1st, then Method2 called after and then Method3 by using the AAA syntax, in Rhino-mocks 3.6 ?

// Assert
var mock = MockRepository.GenerateMock<ISomeService>();

// Act
myObject.Service = mock;

// How should I change this part to ensure that Rhino Mocks check the call order as well?
mock.AssertWasCalled(m=>m.Method1());
mock.AssertWasCalled(m=>m.Method2());
mock.AssertWasCalled(m=>m.Method3());

推荐答案

这是一种方法...

mock.AssertWasCalled(m=>m.Method1(), options => options.WhenCalled(w => mockService.AssertWasNotCalled(x=>x.Method2())));
mock.AssertWasCalled(m=>m.Method2(), options => options.WhenCalled(w => mockService.AssertWasNotCalled(x=>x.Method3())));
mock.AssertWasCalled(m=>m.Method3());

这篇关于我可以在 Rhino-Mocks 3.6 中使用 AAA 语法测试方法调用顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆