TestCase を使用してジェネリック型を NUnit のテストに渡す方法はありますか?
これは私がやりたいことですが、構文が正しくありません...
[Test]
[TestCase<IMyInterface, MyConcreteClass>]
public void MyMethod_GenericCall_MakesGenericCall<TInterface, TConcreteClass>()
{
// Arrange
// Act
var response = MyClassUnderTest.MyMethod<TInterface>();
// Assert
Assert.IsInstanceOf<TConcreteClass>(response);
}
または、そうでない場合、同じ機能を実現するための最良の方法は何ですか (明らかに、実際のコードには複数の TestCase があります)。
別の例で更新...
これは、単一のジェネリック型が渡された別の例です...
[Test]
[TestCase<MyClass>("Some response")]
public void MyMethod_GenericCall_MakesGenericCall<T>(string expectedResponse)
{
// Arrange
// Act
var response = MyClassUnderTest.MyMethod<T>();
// Assert
Assert.AreEqual(expectedResponse, response);
}