本文整理汇总了C#中NUnit.Framework.List.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# List.SequenceEqual方法的具体用法?C# List.SequenceEqual怎么用?C# List.SequenceEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.SequenceEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public void Test()
{
var rand = new Random(3);
List<string> list1 = new List<string>();
WeakList<string> list2 = new WeakList<string>();
for (int x = 0; x < 1000; x++)
{
var str = x.ToString();
list1.Add(str);
list2.Add(str);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
for (int x = 1000; x < 2000; x++)
{
var str = x.ToString();
var removeItem = list1[rand.Next(list1.Count)];
list1.Remove(removeItem);
list2.Remove(removeItem);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
list1.Add(str);
list2.Add(str);
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
for (int x = 0; x < 100; x++)
{
list1.RemoveAt(rand.Next(list1.Count));
GC.Collect();
if (!list1.SequenceEqual(list2))
throw new Exception("Lists are not the same.");
}
list2.Clear();
foreach (var data in list2)
throw new Exception();
}
示例2: TestDifferingLists
public void TestDifferingLists()
{
var x = new List<int> {1, 2, 3, 4, 5, 6};
var y = new List<int> {1, 2, 3, 4, 5, 7};
ApproveException(() => x.SequenceEqual(y));
}
示例3: RemoveWithEmptyItems
public void RemoveWithEmptyItems()
{
ICollection<int> col = new List<int> { 1, 2, 3 };
col.Remove(new int[] { });
Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
}
示例4: RemoveAll
public void RemoveAll()
{
ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };
col.RemoveAll(x => x % 2 == 0);
Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
}
示例5: RemoveItems
public void RemoveItems()
{
ICollection<int> col = new List<int> { 1, 2, 3, 4, 5 };
col.Remove(new int[] { 2, 4 });
Assert.IsTrue(col.SequenceEqual(new [] { 1, 3, 5 }));
}
示例6: story_data_is_observed_during_invocation
public void story_data_is_observed_during_invocation()
{
var data = new List<KeyValuePair<string, object>>()
{
new KeyValuePair<string, object>("bool_value", true),
new KeyValuePair<string, object>("int_value", 123),
new KeyValuePair<string, object>("string_value", "test!"),
};
var handlerRules = new Ruleset<IStory, IStoryHandler>()
{
Rules = {
new PredicateRule(
_ => true, // always run for story
_ => new ActionHandler(
(story) => Assert.AreEqual(0, story.Data.Count()), // make sure OnStart() is invoked with zero data items.
(story, task) => Assert.IsTrue(data.SequenceEqual(story.Data))) // make sure OnStop() is invoked with 3 data items.
),
},
};
new Story("testStory", handlerRules).Run(story =>
{
foreach (var kvp in data)
{
story.Data[kvp.Key] = kvp.Value;
}
});
}
示例7: RemoveWithNullItems
public void RemoveWithNullItems()
{
ICollection<int> col = new List<int> { 1, 2, 3 };
col.Remove((int[])null);
Assert.IsTrue(col.SequenceEqual(new [] { 1, 2, 3 }));
}
示例8: TestGetRandomItemsInNonUniformDistribution
public void TestGetRandomItemsInNonUniformDistribution()
{
var items = GetNonUniformlyDistributedItems(10).ToList();
var randomItemRetriever = new RandomItemRetriever<IProbabilityWeightedItem>(_randomGenerator, items);
var actualItems = Enumerable.Range(0, 10)
.Select(counter => randomItemRetriever.NextItem())
.ToList();
var expectedItems = new List<IProbabilityWeightedItem>
{
items[0],
items[1],
items[1],
items[2],
items[2],
items[2],
items[3],
items[3],
items[3],
items[3]
};
Assert.IsTrue(expectedItems.SequenceEqual(actualItems));
}
示例9: ParseTest
public void ParseTest(List<TimePeriodToken> TimePeriodTokens, List<Shift> expectedShifts)
{
var parser = new ShiftsFactory(TimePeriodTokens, task, date, interval, exceedingAllowed);
var actualShifts = parser.Parse();
Assert.IsTrue(expectedShifts.SequenceEqual<Shift>(actualShifts));
}
示例10: SetEquality
public void SetEquality()
{
var a = new List<int> { 1, 2, 3 };
var b = new List<int> { 1, 2, 3 };
var result = a.SequenceEqual(b);
Assert.IsTrue(result);
}
示例11: TaskFactoryMakeShiftTest
public void TaskFactoryMakeShiftTest(Model.Task test,
List<ShiftsSpecification> shiftSpecList,
List<Model.Shift> expectedShifts)
{
var parser = new TaskFactory();
var actualShifts = parser.MakeShifts(test, shiftSpecList);
Assert.IsTrue(expectedShifts.SequenceEqual(actualShifts));
}
示例12: WorkerFactoryMakeIndisposedTest
public void WorkerFactoryMakeIndisposedTest(Model.Worker test,
List<IndisposedSpecification> indisposedSpecList,
List<Model.Indisposed> expectedIndisposeds)
{
var parser = new WorkerFactory();
var actualShifts = parser.MakeIndisposeds(test, indisposedSpecList);
Assert.IsTrue(expectedIndisposeds.SequenceEqual(actualShifts));
}
示例13: ScanTest
public void ScanTest(string shiftsField, List<TimePeriodToken> expectedTokens)
{
var scanner = new TimePeriodScanner(shiftsField);
scanner.Scan();
var actualTokens = scanner.Tokens;
Assert.IsTrue(expectedTokens.SequenceEqual<TimePeriodToken>(actualTokens));
}
示例14: PedidoTemProdutoCliente
public void PedidoTemProdutoCliente()
{
var clientes = new List<Cliente> { new Cliente("Gabriel") };
var produto = new Produto("batata", 2.99m);
var pedido = new Pedido(produto, clientes);
Assert.AreEqual(produto, pedido.Produto);
Assert.IsTrue(clientes.SequenceEqual(pedido.Clientes), "clientes");
}
示例15: TestValidateAllValidRecords
public void TestValidateAllValidRecords()
{
List<RawStudentInfo> records = new List<RawStudentInfo>
{
new RawStudentInfo{FirstName="John", LastName="Conn", Age="20", Sex = "Male"},
new RawStudentInfo{FirstName="Sarah", LastName="Libouee", Age="25", Sex = "Female"},
new RawStudentInfo{FirstName="Lucia", LastName="Fabi", Age="22", Sex = "Female"}
};
Assert.IsTrue(records.SequenceEqual(stService.GetRecords(records, "En-US").ValidRecords));
}