本文整理汇总了C#中NUnit.Framework.ToDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# NUnit.Framework.ToDataTable方法的具体用法?C# NUnit.Framework.ToDataTable怎么用?C# NUnit.Framework.ToDataTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework
的用法示例。
在下文中一共展示了NUnit.Framework.ToDataTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToDataTable_ReturnsEmptyDataset
public void ToDataTable_ReturnsEmptyDataset()
{
var entities = new[]
{
new MyEntity {Id = 1, Key = "key1", Value = "value1", ForeignKey = 1},
new MyEntity {Id = 2, Key = "key2", Value = "value2", ForeignKey = 2},
new MyEntity {Id = 3, Key = "key3", Value = "value3", ForeignKey = 3},
new MyEntity {Id = 4, Key = "key4", Value = "value4", ForeignKey = 1},
new MyEntity {Id = 5, Key = "key5", Value = "value5", ForeignKey = 2},
new MyEntity {Id = 6, Key = "key6", Value = "value6", ForeignKey = 3},
new MyEntity {Id = 7, Key = "key7", Value = "value7", ForeignKey = 1},
new MyEntity {Id = 8, Key = "key8", Value = "value8", ForeignKey = 2},
new MyEntity {Id = 9, Key = "key9", Value = "value9", ForeignKey = 3},
new MyEntity {Id = 10, Key = "key10", Value = "value10", ForeignKey = 1},
new MyEntity {Id = 11, Key = "key11", Value = "value11", ForeignKey = 2}
};
var result = entities.ToDataTable();
result.Rows.Count.ShouldEqual(11);
for (var i = 1; i <= 11; i++)
{
var row = result.Rows[i - 1];
row["Id"].ShouldEqual(i);
row["Key"].ShouldEqual("key" + i);
row["Value"].ShouldEqual("value" + i);
row["ForeignKey"].ShouldEqual(i%3 == 0 ? 3 : i%3);
}
}