本文整理汇总了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));
}
示例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");
}
示例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]);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}