试图对一个构造函数接受 Func 参数的类进行单元测试。不确定如何使用 Moq 进行模拟。
public class FooBar
{
public FooBar(Func<IFooBarProxy> fooBarProxyFactory)
{
_fooBarProxyFactory = fooBarProxyFactory;
}
}
[Test]
public void A_Unit_Test()
{
var nope = new Mock<Func<IFooBarProxy>>();
var nope2 = new Func<Mock<IFooBarProxy>>();
var fooBar = new FooBar(nope.Object);
var fooBar2 = new FooBar(nope2.Object);
// what's the syntax???
}
Func
,我认为你是从一个Func
中返回了一个模拟对象。 - satnhak