如何提供List作为数据理论的数据源,我在InlineData中找不到支持此功能的任何东西:
[InlineData(null, new[] { 42, 2112 }, null)] // This doesn't work, I need something that works with List<int>
[Trait("Category", "API")]
[Trait("Category", "Partner")]
[Trait("Category", "Smoke")]
public void VerifyGetCarListAsync(int? colorID, List<int> carIDs, int? sellerID){//}
答案 0 :(得分:1)
InlineData
不能实现这一点,您只能使用MemberData
,PropertyData
或ClassData
来做到这一点,请参见下面的MemberData
示例。
[MemberData(nameof(Data))]
public void VerifyGetCarListAsync(int? colorID, List<int> carIDs, int? sellerID){
// test code
}
public static IEnumerable<object[]> Data => {
yield return new object[] { null, new List<int>{ 42, 2112 }, null };
yield return new object[] { 1, new List<int>{ 43, 2112 }, null };
yield return new object[] { null, new List<int>{ 44, 2112 }, 6 };
}