【发布时间】:2009-12-30 19:35:30
【问题描述】:
请原谅我的无知。我正在努力学习 Rhino。
public Foo(Stream stream)
{
if (stream == null) throw new ArgumentNullException("woot");
if (!stream.CanRead) throw new NotSupportedException("sporkish");
if (!stream.CanSeek) throw new NotSupportedException("monkey");
}
我想通过对这些异常进行测试来使用 NUnit 测试来测试此功能。这是对模拟对象的适当使用,还是我实际上需要创建一个特殊的继承类 Stream?如果模拟是合适的,我该如何使用 Rhino 来做到这一点?我可以弄清楚如何从函数中返回虚拟值(我认为),但不是属性。
【问题讨论】:
标签: c# unit-testing mocking rhino-mocks