当我使用 Factory 属性时,有没有办法写出我期望某些输入的某些异常?我知道如何使用 Row 属性来做到这一点,但我需要它来动态生成测试输入。
请参阅下面的测试示例,了解返回所提供字符串的倒数的函数:
[TestFixture]
public class MyTestFixture()
{
private IEnumerable<object[]> TestData
{
get
{
yield return new object[] { "MyWord", "droWyM" };
yield return new object[] { null, null }; // Expected argument exception
yield return new object[] { "", "" };
yield return new object[] { "123", "321" };
}
}
[Test, Factory("TestData")]
public void MyTestMethod(string input, string expectedResult)
{
// Test logic here...
}
}