【发布时间】:2009-09-02 09:09:37
【问题描述】:
是否可以在 Rhino.Mocks 中验证是否调用了指定的构造函数?
考虑以下代码:
public interface IFoo
{
void Bar();
}
public class FooFactory
{
public IFoo CreateInstance(int x, int y)
{
return new Foo(x, y);
}
}
public class Foo : IFoo
{
public Foo(int x, int y)
{
// ... blah
}
public void Bar()
{
// blah...
}
}
[TestFixture]
public class FooFactoryTest
{
[Test]
public void Assert_Foo_Ctor_Called_By_Factory_CreateInstance()
{
MockRepository mocks = new MockRepository();
using (mocks.Record())
{
Expect.Call( /* ???? */ );
}
using(mocks.Playback())
{
new FooFactory().CreateInstance(1, 2);
}
mocks.VerifyAll();
}
}
我想验证 Foo(int, int) 是否被 FooFactory 调用。
【问题讨论】:
标签: c# unit-testing rhino-mocks