Create a base test class that contains tests common to IFoo implementations as follows:
public abstract class TestIFooBase
{
protected IFoo Foo { get; set; }
[SetUp]
public abstract void SetUp();
[Test]
public void ItWorks()
{
Assert.IsTrue(Foo.ItWorks());
}
}
Now create a very small derived class for each implementation that you want to test:
[TestFixture]
public class TestBarAsIFoo : TestIFooBase
{
public override void SetUp()
{
this.Foo = new Bar();
}
}
edit. -, NUnit , , :
[TestFixture(typeof(ArrayList))]
[TestFixture(typeof(List<int>))]
public class IList_Tests<TList> where TList : IList, new()
{
private IList list;
[SetUp]
public void CreateList()
{
this.list = new TList();
}
[Test]
public void CanAddToList()
{
list.Add(1); list.Add(2); list.Add(3);
Assert.AreEqual(3, list.Count);
}
}
, new() . Activator.CreateInstance IFoo TestFixture.