当前位置: 首页>>代码示例>>C#>>正文


C# NUnit.Framework.ToDataTable方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:saturn72,项目名称:Saturn72.Extensions,代码行数:28,代码来源:EnumerableExtensionsTests.cs


注:本文中的NUnit.Framework.ToDataTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。