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


C# List.Nest方法代码示例

本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Nest方法的典型用法代码示例。如果您正苦于以下问题:C# List.Nest方法的具体用法?C# List.Nest怎么用?C# List.Nest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.VisualStudio.TestTools.UnitTesting.List的用法示例。


在下文中一共展示了List.Nest方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestMakeSetCopy_FromRandomList

        public void TestMakeSetCopy_FromRandomList()
        {
            Random random = new Random();

            // build a list
            var list = new List<int>(100);
            Sublist.Generate(100, i => random.Next()).AddTo(list.ToSublist());
            var destination = new List<int>().ToSublist();
            destination = Sublist.Generate(100, 0).AddTo(destination);

            // make it a set
            var result = list.ToSublist().MakeSet().CopyTo(destination);
            destination = destination.Nest(0, result.DestinationOffset);

            // the set should be sorted and have all unique values
            Assert.IsTrue(destination.IsSorted(), "The list was not sorted.");
            Assert.IsFalse(destination.FindDuplicates(), "The list had duplicates.");
        }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:18,代码来源:MakeSetCopyTester.cs

示例2: TestNest_WithCount_OffsetTooBig_Throws

 public void TestNest_WithCount_OffsetTooBig_Throws()
 {
     var list = new List<int>().ToSublist();
     int offset = 1;
     int count = 0;
     list.Nest(offset, count);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例3: TestNest_WithCount_NegativeOffset_Throws

 public void TestNest_WithCount_NegativeOffset_Throws()
 {
     var list = new List<int>().ToSublist();
     int offset = -1;
     int count = 0;
     list.Nest(offset, count);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例4: TestNest_Sublist_OffsetToPopFront

 public void TestNest_Sublist_OffsetToPopFront()
 {
     IMutableSublist<List<int>, int> list = new List<int>() { 1, 2, 3, 4, 5, }.ToSublist();
     var nested = list.Nest(1);
     int[] expected = { 2, 3, 4, 5, };
     Assert.IsTrue(expected.ToSublist().IsEqualTo(nested), "The offset did not pop the first item.");
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例5: TestNest_Sublist_CountToPopBack

 public void TestNest_Sublist_CountToPopBack()
 {
     IMutableSublist<List<int>, int> list = new List<int>() { 1, 2, 3, 4, 5, }.ToSublist();
     var nested = list.Nest(0, list.Count - 1);
     int[] expected = { 1, 2, 3, 4, };
     Assert.IsTrue(expected.ToSublist().IsEqualTo(nested), "The offset did not pop the last item.");
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例6: TestNest_ShiftAndShrink

 public void TestNest_ShiftAndShrink()
 {
     var list = new List<int>() { 1, 2, 3, 4, 5, }.ToSublist();
     var nested = list.Nest(1, list.Count - 2); // we want to remove the front and back, two items
     int[] expected = { 2, 3, 4, };
     Assert.IsTrue(expected.ToSublist().IsEqualTo(nested), "The offset did not pop the last item.");
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例7: TestNest_RepresentPartitions

 public void TestNest_RepresentPartitions()
 {
     var list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }.ToSublist();
     int partition = list.Partition(i => i % 2 == 0).InPlace(); // put evens in the front
     var evens = list.Nest(0, partition);
     var odds = list.Nest(partition);
     Assert.IsFalse(evens.Find(i => i % 2 != 0), "Not all evens in the first nested list.");
     Assert.IsFalse(odds.Find(i => i % 2 == 0), "Not all odds in the second nested list.");
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:9,代码来源:SublistTester.cs

示例8: TestNest_OffsetTooBig_Throws

 public void TestNest_OffsetTooBig_Throws()
 {
     var list = new List<int>().ToSublist();
     int offset = 1;
     list.Nest(offset);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:6,代码来源:SublistTester.cs

示例9: TestNest_NegativeOffset_Throws

 public void TestNest_NegativeOffset_Throws()
 {
     var list = new List<int>().ToSublist();
     int offset = -1;
     list.Nest(offset);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:6,代码来源:SublistTester.cs

示例10: TestNest_DoublyNested_AdjustsCount

 public void TestNest_DoublyNested_AdjustsCount()
 {
     var list = new List<int>() { 1, 2, 3, 4, 5, }.ToSublist();
     var nested = list.Nest(1).Nest(1);
     int[] expected = { 3, 4, 5, };
     Assert.IsTrue(expected.ToSublist().IsEqualTo(nested), "The offset did not pop the first item.");
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs

示例11: TestNest_CountTooBig_Throws

 public void TestNest_CountTooBig_Throws()
 {
     var list = new List<int>() { 1, 2, 3, 4, 5 }.ToSublist();
     int offset = 1;
     int count = 5; // one too big
     list.Nest(offset, count);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SublistTester.cs


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