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


C# List.SequenceEqual方法代码示例

本文整理汇总了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();
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:48,代码来源:WeakListTest.cs

示例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));
        }
开发者ID:icool123,项目名称:PowerAssert.Net,代码行数:7,代码来源:EndToEndTest.cs

示例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 }));
        }
开发者ID:shchimisyaotsel,项目名称:iSynaptic.Commons,代码行数:7,代码来源:CollectionExtensionsTests.cs

示例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 }));
        }
开发者ID:shchimisyaotsel,项目名称:iSynaptic.Commons,代码行数:7,代码来源:CollectionExtensionsTests.cs

示例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 }));
        }
开发者ID:shchimisyaotsel,项目名称:iSynaptic.Commons,代码行数:7,代码来源:CollectionExtensionsTests.cs

示例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;
                }
            });
        }
开发者ID:amitapl,项目名称:logmetry,代码行数:29,代码来源:CoreTests.cs

示例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 }));
        }
开发者ID:shchimisyaotsel,项目名称:iSynaptic.Commons,代码行数:7,代码来源:CollectionExtensionsTests.cs

示例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));
        }
开发者ID:Talisan,项目名称:Terrastructor,代码行数:25,代码来源:RandomItemRetrieverTest.cs

示例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));
        }
开发者ID:DeStuderendesErhvervskontakt,项目名称:ProjectPlanner,代码行数:8,代码来源:ShiftsFactoryTests.cs

示例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);
        }
开发者ID:korz,项目名称:MathIsEverywhere,代码行数:9,代码来源:IntegerTests.cs

示例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));
        }
开发者ID:DeStuderendesErhvervskontakt,项目名称:ProjectPlanner,代码行数:9,代码来源:TaskFactoryTest.cs

示例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));
        }
开发者ID:DeStuderendesErhvervskontakt,项目名称:ProjectPlanner,代码行数:9,代码来源:WorkerFactoryTests.cs

示例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));
        }
开发者ID:DeStuderendesErhvervskontakt,项目名称:ProjectPlanner,代码行数:9,代码来源:ShiftsScannerTests.cs

示例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");
        }
开发者ID:GabrielMCardozo,项目名称:BarMode,代码行数:10,代码来源:PedidoTest.cs

示例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));
        }
开发者ID:MarkiyanFostyak,项目名称:StudentTrackerService,代码行数:11,代码来源:ExcelParserTests.cs


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