我有一个POCO课程:
public class SomeEntity { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
我想在SomeEntity类中使用不同的值测试其他一些类.问题是我需要测试许多属性的不同组合.例如:
Id = 1,FirstName = null,LastName ="Doe"
Id = 1,FirstName ="",LastName ="Doe"
Id = 1,FirstName ="John",LastName ="Doe"
Id = 1,FirstName = null,LastName =""
等等
所以在每个测试中我想创建这样的测试对象:
// test that someOtherObject always return the same result // for testObject with ID = 1 and accepts any values from range of // values for FirstName and LastName var testObject = new SomeEntity { Id = 1, // this must be always 1 for this test FirstName = It.IsIn(someListOfPossibleValues), // each of this values must be accepted in test LastName = It.IsIn(someListOfPossibleValues) // each of this values must be accepted in test } var result = someOtherObject.DoSomething(testObject); Assert.AreEqual("some expectation", result);
我不想使用nunit TestCase,因为会有很多组合(巨大的矩阵).
我尝试在调试中运行此测试,它只使用list中的第一个值调用DoSomething一次.
问题:如何结合所有可能的值?