我有一个界面IFoo
public interface IFoo
{
void DoSomeStuff();
}
我有两种派生类型FooImpl1
和FooImpl2
:
public class FooImpl1 : IFoo
{
public void DoSomeStuff()
{
//...
}
}
public class FooImpl2 : IFoo
{
public void DoSomeStuff()
{
//Should do EXACTLY the same job as FooImpl1.DoSomeStuff()
}
}
我有一个测试类测试IFoo
合同FooImpl1
:
private static IFoo FooFactory()
{
return new FooImpl1();
}
[Fact]
public void TestDoSomeStuff()
{
IFoo foo = FooFactory();
//Assertions.
}
我怎样才能重用这个测试类来测试FooImpl1
和FooImpl2
?