本文整理汇总了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.");
}
示例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);
}
示例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);
}
示例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.");
}
示例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.");
}
示例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.");
}
示例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.");
}
示例8: TestNest_OffsetTooBig_Throws
public void TestNest_OffsetTooBig_Throws()
{
var list = new List<int>().ToSublist();
int offset = 1;
list.Nest(offset);
}
示例9: TestNest_NegativeOffset_Throws
public void TestNest_NegativeOffset_Throws()
{
var list = new List<int>().ToSublist();
int offset = -1;
list.Nest(offset);
}
示例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.");
}
示例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);
}