下面是我的测试代码:
[Test]
public void Test_Delete_ShouldCancelLayoutView()
{
Expect.Call(TreeMasterService.Delete(1, null)).Return(null).IgnoreArguments();
Mocks.ReplayAll();
TestController.Delete(1);
}以下是被测试者:
public void Delete(int id)
{
TreeMasterService.Delete(id, CurrentUser);
CancelLayout();
CancelView();
}有没有办法确保用Rhino Mock调用CancelLayout()和CancelView()?
发布于 2010-11-02 00:15:12
不是的。
像Rhino这样的免费模拟框架可以有效地为测试中的类创建一个透明的代理。因此,根据设计,您只能对接口方法和虚方法进行操作。对于上面这样的东西,你要么需要MS Moles框架,要么需要像Typemock这样的商业工具。
HTH
托马斯
https://stackoverflow.com/questions/4070662
复制相似问题