如何为数据论提供 List<int>? "InlineData"
How to provide List<int> for a data theory ? "InlineData"
如何提供 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){//}
这无法通过 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 };
}
如何提供 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){//}
这无法通过 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 };
}