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


C# List.Merge方法代码示例

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


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

示例1: TestMergeKeepDuplicates

 public void TestMergeKeepDuplicates()
 {
     var arg = new List<List<int>> { new List<int> { 1, 3, 5 }, new List<int> { -1, 1, 2, 4 }, new List<int> { 6, 7 } };
     var expected = new List<int> { -1, 1, 1, 2, 3, 4, 5, 6, 7 };
     var res = arg.Merge(false).ToList();
     Assert.IsTrue(expected.SequenceEqual(res), "Merge of [{0}] with duplicates gives {1} instead of {2}", string.Join(", ", arg.Select(IntsToString)), IntsToString(res), IntsToString(expected));
 }
开发者ID:NorthNick,项目名称:hydra,代码行数:7,代码来源:ExtensionsTest.cs

示例2: TestMergeIsLazy

 public void TestMergeIsLazy()
 {
     // Elements go -4, -2, error, ...
     var badlist = Enumerable.Range(-2, 5).Select(i => i == 0 ? 1 / i : 2 * i);
     var arg = new List<IEnumerable<int>> { badlist, Enumerable.Range(-5, 5), Enumerable.Range(-3, 5) };
     var expected = new List<int> {-5, -4, -3, -2};
     var res = arg.Merge().Take(4);
     Assert.IsTrue(expected.SequenceEqual(res), "Partial enumeration of sequence merge should not raise an error");
 }
开发者ID:NorthNick,项目名称:hydra,代码行数:9,代码来源:ExtensionsTest.cs

示例3: MergeTest

        public void MergeTest()
        {
            List<int> l1 = new List<int>() {1, 3, 5};
            List<int> l2 = new List<int>() { 2, 4 };
            IList<int> merged = l1.Merge(l2);

            Assert.AreEqual(1, merged[0]);
            Assert.AreEqual(2, merged[1]);
            Assert.AreEqual(3, merged[2]);
            Assert.AreEqual(4, merged[3]);
            Assert.AreEqual(5, merged[4]);
        }
开发者ID:rajeevag,项目名称:Algorithms,代码行数:12,代码来源:IListExtensionTests.cs

示例4: TestMergeCopy_WithComparison_NullList2_Throws

 public void TestMergeCopy_WithComparison_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     Func<int, int, int> comparison = Comparer<int>.Default.Compare;
     list1.Merge(list2, comparison);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:MergeCopyTester.cs

示例5: TestMergeCopy_WithComparer_NullDestination_Throws

 public void TestMergeCopy_WithComparer_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     IComparer<int> comparer = Comparer<int>.Default;
     list1.Merge(list2, comparer).CopyTo(destination);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:8,代码来源:MergeCopyTester.cs

示例6: TestMergeCopy_NullList2_Throws

 public void TestMergeCopy_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     list1.Merge(list2);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:6,代码来源:MergeCopyTester.cs

示例7: TestMergeCopy_NullDestination_Throws

 public void TestMergeCopy_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     list1.Merge(list2).CopyTo(destination);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:MergeCopyTester.cs

示例8: TestMergeCopy_NullComparison_Throws

 public void TestMergeCopy_NullComparison_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     Func<int, int, int> comparison = null;
     list1.Merge(list2, comparison);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:MergeCopyTester.cs

示例9: TestMergeCopy_NullComparer_Throws

 public void TestMergeCopy_NullComparer_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IComparer<int> comparer = null;
     list1.Merge(list2, comparer);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:MergeCopyTester.cs

示例10: TestMergeAdd_WithComparison_NullDestination_Throws

 public void TestMergeAdd_WithComparison_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     Func<int, int, int> comparison = Comparer<int>.Default.Compare;
     list1.Merge(list2, comparison).AddTo(destination);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:8,代码来源:MergeAddTester.cs

示例11: TestMergeAdd_WithComparer_NullList2_Throws

 public void TestMergeAdd_WithComparer_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     IComparer<int> comparer = Comparer<int>.Default;
     list1.Merge(list2, comparer);
 }
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:MergeAddTester.cs


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