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


C# List.SequenceEqual方法代码示例

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


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

示例1: TestEqualityBuilder

        public void TestEqualityBuilder()
        {
            IEnumerable<Tester> a = new List<Tester>
            {
                new Tester(1, 2),
                new Tester(3, 4),
                new Tester(4, 10),
                new Tester(10, 12),
                new Tester(14, 432)
            };
            IEnumerable<Tester> b = new List<Tester>
            {
                new Tester(1, 2),
                new Tester(3, 4),
                new Tester(4, 10),
                new Tester(10, 12),
                new Tester(14, 432)
            };

            // Demonstrate that standard method returns false as references are different
            Assert.IsFalse(a.SequenceEqual(b));

            // Demonstrate the using an equality builder allows deeper comparison
            Assert.IsTrue(a.SequenceEqual(b, new EqualityBuilder<Tester>((x, y) => x.A == y.A && x.B == y.B)));
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:25,代码来源:TestComparer.cs

示例2: GenerateFibonacciNumbersListTest

        public void GenerateFibonacciNumbersListTest()
        {
            List<int> fibonacciNumbers = new List<int>();

            fibonacciNumbers = FluentMath.Get().FibonacciNumbers.ToValue(89);
            Assert.IsTrue(fibonacciNumbers.SequenceEqual(new List<int>() { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }));
            fibonacciNumbers = FluentMath.Get().FibonacciNumbers.ToValue(13);
            Assert.IsTrue(fibonacciNumbers.SequenceEqual(new List<int>() { 0, 1, 1, 2, 3, 5, 8, 13 }));
        }
开发者ID:JonasGo,项目名称:FluentMath,代码行数:9,代码来源:FibonacciTest.cs

示例3: TestAdd

        public void TestAdd()
        {
            var cpu = new CPU();

            //Set initial values in register file
            cpu.RegWrite(2, 10);
            cpu.RegWrite(3, 255);

            const string instr = "add $1, $2, $3";
            cpu.AddInstruction(new Add(instr, 0, 1, 2, 3));

            var expectedRecords = new List<ExecutionRecordList>();
            int clockCycle = 0;

            cpu.RunClock();
            expectedRecords.Add(new ExecutionRecordList());
            expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Fetch, instr, 0, null));
            clockCycle++;
            Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));

            cpu.RunClock();
            expectedRecords.Add(new ExecutionRecordList());
            expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Decode, "Add: rd = $1, rs = $2, rt = $3", 0, null));
            clockCycle++;
            Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));

            cpu.RunClock();
            expectedRecords.Add(new ExecutionRecordList());
            expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Execute, "Add 10 + 255 = 265", 0, null));
            clockCycle++;
            Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));

            cpu.RunClock();
            expectedRecords.Add(new ExecutionRecordList());
            expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Memory, "None", 0, null));
            clockCycle++;
            Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));

            cpu.RunClock();
            expectedRecords.Add(new ExecutionRecordList());
            expectedRecords[clockCycle].Add(new ExecutionRecord(ExecutionType.Writeback, "Register $1 <= 265", 0, null));
            clockCycle++;
            Assert.IsTrue(expectedRecords.SequenceEqual(cpu.ExecutionRecords));

            //Test value inside register file
            Assert.AreEqual(265, cpu.RegRead(1));
            Assert.AreEqual(clockCycle, cpu.ClockCycle);
        }
开发者ID:Gabrola,项目名称:MipSim,代码行数:48,代码来源:InstructionTests.cs

示例4: CategorySortComparison

        public void CategorySortComparison()
        {
            var l = new List<Category>
                                   {
                                       new Category("Hello"),
                                       new Category("Hello", "GoodBye"),
                                       new Category("Hello", "A"),
                                       new Category("Hello", "B"),
                                       new Category("A"),
                                       new Category("Z")
                                   };

            var lSorted = new List<Category>
                                   {
                                       new Category("A"),
                                       new Category("Hello"),
                                       new Category("Hello", "A"),
                                       new Category("Hello", "B"),
                                       new Category("Hello", "GoodBye"),
                                       new Category("Z")
                                   };

            Assert.IsFalse(l.SequenceEqual(lSorted));
            l.Sort();
            Assert.IsTrue(l.SequenceEqual(lSorted));
        }
开发者ID:nithinphilips,项目名称:SMOz,代码行数:26,代码来源:EqualityTests.cs

示例5: CalculatedRecurrenceSetPagingWorks

            public void CalculatedRecurrenceSetPagingWorks()
            {
                #region Arrange

                var validStartDateTime = new DateTime(2014, 1, 31);
                const int validMonthsBetweenOccurrences = 2;
                DateTime validEndDateTime = validStartDateTime.AddMonths(9);
                var validDayOfWeekMonthlyRecurrence = new DayOfWeekMonthlyRecurrence(validStartDateTime,
                    validMonthsBetweenOccurrences, validEndDateTime);

                var expectedRecurrenceSet = new List<DateTime>
                {
                    new DateTime(2014, 3, 28), // 3/28/2014 (March)
                    new DateTime(2014, 5, 30), // 5/30/2014 (May)
                };

                #endregion

                #region Act

                const int validSkip = 1;
                const int validTake = 2;
                IEnumerable<DateTime> recurrenceSet = validDayOfWeekMonthlyRecurrence.CalculateRecurrenceSet(validSkip,
                    validTake);

                #endregion

                #region Assert

                Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));

                #endregion
            }
开发者ID:TonightWe,项目名称:TW.Recurrence,代码行数:33,代码来源:DayOfWeekMonthlyRecurrenceTests.cs

示例6: CanFindAllIndexes

        public void CanFindAllIndexes()
        {
            var expected = new List<int> { 1, 4, 5 };

            var actual = this.array.FindAllIndexes(0, new int[0], 1);
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
开发者ID:austinedeveloper,项目名称:Orc.CollectionValidator,代码行数:7,代码来源:ExtensionsTest.cs

示例7: TestAdjacent

        public void TestAdjacent()
        {
            IMatrix<string> matrix = new Matrix<string>(3, 3);
            List<string> items = new List<string>(9);
            for (int i = 0; i < items.Capacity; i++)
            {
                items.Add(string.Format("{0}", i));
            }

            var index = 0;
            for (int y = 0; y < matrix.Rows; y++)
            {
                int x;
                for (x = 0; x < matrix.Columns; x++)
                {
                    matrix[x, y] = items[index++];
                }
            }

            var middleCell = matrix[1, 1];
            int middleIndex = matrix.IndexOf(middleCell);
            items.RemoveAt(middleIndex);

            var adjacentCells = matrix.GetAdjacentCells(middleCell);
            Assert.IsTrue(items.SequenceEqual(adjacentCells));
        }
开发者ID:mattmemmesheimer,项目名称:minesearch-reboot,代码行数:26,代码来源:MatrixTest.cs

示例8: CanCalculateRecurrenceSet

            public void CanCalculateRecurrenceSet()
            {
                #region Arrange

                var validStartDateTime = new DateTime(2014, 2, 18);
                const int validDaysBetweenOccurrences = 3;
                var validEndDateTime = validStartDateTime.AddDays(validDaysBetweenOccurrences*3);
                var validDailyRecurrence = new DailyRecurrence(validStartDateTime, validDaysBetweenOccurrences,
                    validEndDateTime);

                #endregion

                #region Act

                var recurrenceSet = validDailyRecurrence.CalculateRecurrenceSet();

                #endregion

                #region Assert

                var expectedRecurrenceSet = new List<DateTime>
                {
                    validStartDateTime,
                    validStartDateTime.AddDays(validDaysBetweenOccurrences*1),
                    validStartDateTime.AddDays(validDaysBetweenOccurrences*2),
                    validStartDateTime.AddDays(validDaysBetweenOccurrences*3)
                };

                Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));

                #endregion
            }
开发者ID:TonightWe,项目名称:TW.Recurrence,代码行数:32,代码来源:DailyRecurrenceTests.cs

示例9: GetAllWithFullNameTest

 public void GetAllWithFullNameTest()
 {
     var ds = new List<string> { "DARTFORD", "LIVERPOOL", "PADDINGTON" };
     var expressions = new List<string>{ "LIVERPOOL" };
     var result = new DictionaryStationRepository(ds).GetAllThatStartWith("LIVERPOOL");
     Assert.IsTrue(expressions.SequenceEqual(result));
 }
开发者ID:RMinas,项目名称:TrainTicketMachine,代码行数:7,代码来源:DictionaryStationRepositoryTests.cs

示例10: GetAllWithMissingNameTest

 public void GetAllWithMissingNameTest()
 {
     var ds = new List<string> { "EUSTON", "LONDON BRIDGE", "VICTORIA" };
     var expressions = new List<string>(0);
     var result = new DictionaryStationRepository(ds).GetAllThatStartWith("KINGS CROSS");
     Assert.IsTrue(expressions.SequenceEqual(result));
 }
开发者ID:RMinas,项目名称:TrainTicketMachine,代码行数:7,代码来源:DictionaryStationRepositoryTests.cs

示例11: ReturnFirst10FibonacciNumberWhenInputIs10

 public void ReturnFirst10FibonacciNumberWhenInputIs10()
 {
     var expectedResult = new List<ulong> { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
     var result = Fibonacci.GetNumbers(10);
     Assert.IsTrue(expectedResult.SequenceEqual(result.Numbers),
         "Expected first 10 Fibonacci numbers; got something else");
 }
开发者ID:aaronshaver,项目名称:FibonacciGenerator,代码行数:7,代码来源:FibonacciTests.cs

示例12: SerializeDeserializeList1

 public void SerializeDeserializeList1()
 {
     var l = new List<string>();
     var l2 = l.Serialize().Deserialize<List<string>>();
     Assert.IsTrue(l.SequenceEqual(l2));
     Assert.AreNotSame(l, l2);
 }
开发者ID:pkubryk,项目名称:SummerBatch,代码行数:7,代码来源:SerializationUtilsTests.cs

示例13: GetAllWithPartialNameTest

 public void GetAllWithPartialNameTest()
 {
     var ds = new List<string> { "DARTFORD", "DARTMOUTH", "TOWER HILL", "DERBY" };
     var expressions = new List<string> { "DARTFORD", "DARTMOUTH" };
     var result = new DictionaryStationRepository(ds).GetAllThatStartWith("DART");
     Assert.IsTrue(expressions.SequenceEqual(result));
 }
开发者ID:RMinas,项目名称:TrainTicketMachine,代码行数:7,代码来源:DictionaryStationRepositoryTests.cs

示例14: 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

示例15: CanCalculateRecurrenceSet

            public void CanCalculateRecurrenceSet()
            {
                #region Arrange

                var validStartDateTime = new DateTime(2014, 1, 31);
                const int validMonthsBetweenOccurrences = 2;
                DateTime validEndDateTime = validStartDateTime.AddMonths(9);
                var validDayOfWeekMonthlyRecurrence = new DayOfWeekMonthlyRecurrence(validStartDateTime,
                    validMonthsBetweenOccurrences, validEndDateTime);

                var expectedRecurrenceSet = new List<DateTime>
                {
                    new DateTime(2014, 1, 31), // 1/31/2014 (January)
                    new DateTime(2014, 3, 28), // 3/28/2014 (March)
                    new DateTime(2014, 5, 30), // 5/30/2014 (May)
                    new DateTime(2014, 7, 25), // 7/25/2014 (July)
                    new DateTime(2014, 9, 26) // 9/26/2014 (September)
                };

                #endregion

                #region Act

                IEnumerable<DateTime> recurrenceSet = validDayOfWeekMonthlyRecurrence.CalculateRecurrenceSet();

                #endregion

                #region Assert

                Assert.IsTrue(expectedRecurrenceSet.SequenceEqual(recurrenceSet));

                #endregion
            }
开发者ID:TonightWe,项目名称:TW.Recurrence,代码行数:33,代码来源:DayOfWeekMonthlyRecurrenceTests.cs


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