lundi 30 novembre 2015

NUnit 3 with generics

I saw this post here NUnit: Parametric test with generic methods for NUnit 2.5:

[TestCase((int)5, "5")]
[TestCase((double)2.3, "2.3")]
public void TestRowTestGeneric<T>(T value, string msg)
{
   Assert.AreEqual(value, ConvertStrToGenericParameter<T>(msg));
}

But looks it's not working anymore for NUnit 3.0?

What would be the right way for this scenario?

[Test]
[TestCase(0)]
[TestCase(FakeEnum.DefaultValue)]
public void should_expect_T_value<T>(T expectedValue)
{
   var result = DoStuff<T>();
   Assert.AreEqual(expectedValue, result);
}

Thanks

Aucun commentaire:

Enregistrer un commentaire