2
我有一個接口IFoo
使用Xunit測試多個派生類型的最佳方法是什麼?
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
?
謝謝
聽起來像一個完美的解決方案,非常感謝你! –
任何想法如何讓這個工作與'xunit 2'和'reshaper-xunit'?對於共享的事實,我得到'抽象fixture的測試不能自行運行'。 – georgiosd