无效方法的Nunit [英] Nunit for void methods

查看:85
本文介绍了无效方法的Nunit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是nunit的新手.从文档中我了解到,当方法返回一些值时,我们可以进行测试.然后
如何使用nunit测试void方法.
这些方法具有连接功能.

我需要使用存根还是可以使用模拟对象?
请帮我举个简单的例子.

Hi

i am new to nunit. from the docs i understand we can do the testing when the method returns some values.then
how can i Test the void methods using nunit.
the methods does the connectivity functionality.

do i need to use stubs or mock objects can be used.
pls do help me with simple example.

推荐答案

using (MockRepository.Record())
{
   mockedObject.Expect(mock=>mock.VoidMethod(expectedParameterIfAny));
}
using(MockRepository.PlayBack())
{
   objectToTest->SomeMethod();
}


这篇关于无效方法的Nunit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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