从摩尔手册:
集会
Microsoft.Moles.NUnit.dll 您必须通过在 NUnit bin/addins文件夹中复制 Microsoft.Moles.NUnit.dll 程序集来向 NUnit 注册该加载项。
NUnit 版本
2.5.2.9222(对于其他 NUnit 版本,从源重新编译属性)
示例用法
using NUnit.Framework;
using Microsoft.Moles.Framework.NUnit;
[TestFixture]
public class NUnitTest
{
[Test]
[Moled] // set up of the mole context around the test case
public void TestWithMoles() {
...
}
// alternative not using [Moled]
[Test]
public void TestWithMoles() {
using(MolesContext()) { // clears moles leaving context
...
}
}
}
命令行
确保在调用 NUnit 控制台运行程序时使用 /domain=None 参数。
moles.runner.exe /r:nunit-console.exe /args=”/domain=None” ..