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


C# Assert.DeepEqual方法代码示例

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


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

示例1: Test

        public static void Test(Assert assert)
        {
            assert.Expect(4);

            // TEST
            int[] numbersA = { 4, 1, 3 };
            int[] numbersB = { 2, 3, 5 };

            var concatNumbers = numbersA.Concat(numbersB);
            assert.DeepEqual(concatNumbers, new[] { 4, 1, 3, 2, 3, 5 }, "Concat() numbers");

            // TEST
            var names = from p in Person.GetPersons()
                        select p.Name;
            var cities = from p in Person.GetPersons()
                         select p.City;
            var concatNames = names.Concat(cities).ToArray();

            assert.DeepEqual(concatNames,
                            new[] { "Frank", "Zeppa", "John", "Billy", "Dora", "Ian", "Mary", "Nemo",
                                    "Edmonton", "Tokyo", "Lisbon", "Paris", "Budapest", "Rome", "Dortmund", "Ocean"},
                            "Concat() two sequences");

            // TEST
            var a = new[] { "a", "b", "z" };
            var b = new[] { "a", "b", "z" };

            assert.Ok(a.SequenceEqual(b), "SequenceEqual() for equal sequences");

            // TEST
            var c = new[] { "a", "b", "z" };
            var d = new[] { "a", "z", "b" };

            assert.Ok(!c.SequenceEqual(d), "SequenceEqual() for not equal sequences");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:35,代码来源:TestLinqMiscellaneousOperators.cs

示例2: Test

        public static void Test(Assert assert)
        {
            assert.Expect(2);

            // TEST
            var numbers = (from n in Enumerable.Range(0, 6)
                           select new
                           {
                               Number = n,
                               IsOdd = n % 2 == 1
                           }).ToArray();
            var numbersExpected = new object[] {
                 new { Number = 0, IsOdd = false},
                 new { Number = 1, IsOdd = true},
                 new { Number = 2, IsOdd = false},
                 new { Number = 3, IsOdd = true},
                 new { Number = 4, IsOdd = false},
                 new { Number = 5, IsOdd = true},
                 };

            assert.DeepEqual(numbers, numbersExpected, "Range() 6 items from 0");

            // TEST
            var repeatNumbers = Enumerable.Repeat(-3, 4).ToArray();
            var repeatNumbersExpected = new[] { -3, -3, -3, -3 };

            assert.DeepEqual(repeatNumbers, repeatNumbersExpected, "Repeat() -3 four times");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:28,代码来源:TestLinqGenerationOperators.cs

示例3: Test

        public static void Test(Assert assert)
        {
            assert.Expect(5);

            // TEST
            var numbers = new[] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
            var filteredNumbers = (from n in numbers where n <= 6 select n).ToArray();
            assert.DeepEqual(filteredNumbers, new[] { 5, 4, 1, 3, 6, 2, 0 }, "Where elements in integer array are below or equal 6");

            // TEST
            var filteredCounts = (from p in Person.GetPersons() where p.Count < 501 select p.Count).ToArray();
            assert.DeepEqual(filteredCounts, new[] {300, 100, 500, 50 }, "Where elements in Person array have Count below 501");

            // TEST
            filteredCounts = (from p in Person.GetPersons() where p.Count < 501 && p.Group == "A" select p.Count).ToArray();
            assert.DeepEqual(filteredCounts, new[] { 300 }, "Where elements in Person array have Count below 501 ang in group 'A'");

            // TEST
            var persons = Person.GetPersons();
            var filteredPersonByCounts = (from p in Person.GetPersons() where p.Count < 501 select p).ToArray();

            assert.DeepEqual(filteredPersonByCounts, new[] { persons[0], persons[1], persons[3], persons[4] },
                "Where elements in Person array have Count below 501. Returns Person instances");

            // TEST
            var filteredPersonByCountAndIndex = persons.Where((p, index) => p.Count < index * 100).ToArray();

            assert.DeepEqual(filteredPersonByCountAndIndex, new[] { persons[4] },
                "Where elements in Person array have Count meet condition (p.Count < index * 100). Returns Person instances");
        }
开发者ID:txdv,项目名称:Testing,代码行数:30,代码来源:TestLinqRestrictionOperators.cs

示例4: Test

        public static void Test(Assert assert)
        {
            assert.Expect(6);

            // TEST
            int[] numbers = new int[] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
            int i = 0;

            var aQuery = from n in numbers select ++i;
            assert.Equal(i, 0, "Query is not executed until you enumerate over them");

            // TEST
            aQuery.ToList();
            assert.Equal(i, 10, "Query is  executed after you enumerate over them");

            i = 0;

            // TEST
            var bQuery = (from n in numbers select ++i).Max();
            assert.Equal(i, 10, "Max() executes immediately");

            // TEST
            var smallNumbers = from n in numbers where n <= 3 select n;
            var smallerEvenNumbers = from n in smallNumbers where n % 2 == 0 select n;
            assert.DeepEqual(smallerEvenNumbers.ToArray(), new[] { 2, 0 }, "Query in a query");

            // TEST
            numbers.ForEach((x, index) => numbers[index] = -numbers[index]);
            assert.DeepEqual(numbers.ToArray(), new int[] { -5, -4, -1, -3, -9, -8, -6, -7, -2, 0 }, "ForEach()");

            // TEST
            assert.DeepEqual(smallerEvenNumbers.ToArray(), new[] { -4, -8, -6, -2, 0 }, "Second query run on a modified source");
        }
开发者ID:txdv,项目名称:Testing,代码行数:33,代码来源:TestLinqQueryExecution.cs

示例5: TestUseCase

        public static void TestUseCase(Assert assert)
        {
            assert.Expect(3);

            var list = new List<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            assert.DeepEqual(list.GetRange(0, 2).ToArray(), new[] { 1, 2 }, "Bridge532 (0, 2)");
            assert.DeepEqual(list.GetRange(1, 2).ToArray(), new[] { 2, 3 }, "Bridge532 (1, 2)");
            assert.DeepEqual(list.GetRange(6, 3).ToArray(), new[] { 7, 8, 9 }, "Bridge532 (6, 3)");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:10,代码来源:N532.cs

示例6: Test

        public static void Test(Assert assert)
        {
            assert.Expect(4);

            // TEST
            string[] words = { "count", "tree", "mount", "five", "doubt" };
            bool anyOu = words.Any(w => w.Contains("ou"));
            assert.Ok(anyOu, "Any() to return words containing 'ou'");

            // TEST
            int[] oddNumbers = { 3, 7, 9, 5, 247, 1000001 };
            bool onlyOdd = oddNumbers.All(n => n % 2 == 1);
            assert.Ok(onlyOdd, "All() is odd");

            // TEST
            int[] someNumbers = { 2, 3, 7, 9, 5, 247, 1000001 };
            bool notOnlyOdd = !someNumbers.All(n => n % 2 == 1);
            assert.Ok(notOnlyOdd, "All() is not only odd");

            // TEST
            var productGroups =
                    (from p in Person.GetPersons()
                     group p by p.Group into pGroup
                     where pGroup.Any(p => p.Count >= 500)
                     select new { Group = pGroup.Key, Names = pGroup.Select(x => x.Name).ToArray() }).ToArray();

            object[] productGroupsExpected = { new {Group = "C", Names = new[]{"Zeppa", "Billy"}},
                                                 new {Group = "B", Names = new[]{"John", "Dora", "Ian", "Mary"}},
                                                 new {Group = (string)null, Names = new[]{"Nemo"}}
                                             };

            assert.DeepEqual(productGroups, productGroupsExpected, "Any() to return a grouped array of names only for groups having any item with Count > 500");
        }
开发者ID:txdv,项目名称:Testing,代码行数:33,代码来源:TestLinqQuantifiers.cs

示例7: Test

        public static void Test(Assert assert)
        {
            // TEST
            int[] a = { 1, 2 };
            int[] b = { 1, 2 };

            var result = a.Intersect(b).ToArray();

            assert.Expect(8);

            // TEST
            int[] numbers = { 1, 2, 3, 3, 1, 5, 4, 2, 3 };

            var uniqueNumbers = numbers.Distinct().ToArray();
            assert.DeepEqual(uniqueNumbers, new[] { 1, 2, 3, 5, 4 }, "Distinct() to remove duplicate elements");

            // TEST
            var distinctPersonGroups = (from p in Person.GetPersons() select p.Group).Distinct().ToArray();
            assert.DeepEqual(distinctPersonGroups, new[] { "A", "C", "B", null }, "Distinct() to remove duplicate Group elements");

            // TEST
            int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
            int[] numbersB = { 1, 3, 5, 7, 8 };

            var uniqueNumbersAB = numbersA.Union(numbersB).ToArray();
            assert.DeepEqual(uniqueNumbersAB, new[] { 0, 2, 4, 5, 6, 8, 9, 1, 3, 7 }, "Union() to get unique number sequence");

            // TEST
            var nameChars = from p in Person.GetPersons() select p.Name[0];
            var cityChars = from p in Person.GetPersons() select p.City[0];
            var uniqueFirstChars = nameChars.Union(cityChars).ToArray();

            assert.DeepEqual(uniqueFirstChars, new[] { (int)'F', (int)'Z', (int)'J', (int)'B', (int)'D', (int)'I', (int)'M', (int)'N',
                                                        (int)'E', (int)'T', (int)'L', (int)'P', (int)'R', (int)'O' },
                "Union to get unique first letters of Name and City");

            // TEST
            var commonNumbersCD = numbersA.Intersect(numbersB).ToArray();
            assert.DeepEqual(commonNumbersCD, new[] { 5, 8 }, "Intersect() to get common number sequence");

            // TEST
            nameChars = from p in Person.GetPersons() select p.Name[0];
            cityChars = from p in Person.GetPersons() select p.City[0];

            var commonFirstChars = nameChars.Intersect(cityChars).ToArray();
            assert.DeepEqual(commonFirstChars, new[] { (int)'B', (int)'D' }, "Intersect() to get common first letters of Name and City");

            // TEST
            var exceptNumbersCD = numbersA.Except(numbersB).ToArray();
            assert.DeepEqual(exceptNumbersCD, new[] { 0, 2, 4, 6, 9 },
                "Except() to get numbers from first sequence and does not contain the second sequence numbers");

            // TEST
            var exceptFirstChars = nameChars.Except(cityChars).ToArray();
            assert.DeepEqual(exceptFirstChars, new[] { (int)'F', (int)'Z', (int)'J', (int)'I', (int)'M', (int)'N' },
                "Except() to get letters from Name sequence and does not contain City letters");
        }
开发者ID:txdv,项目名称:Testing,代码行数:57,代码来源:TestLinqSetOperators.cs

示例8: TestCreateLabel

        private static void TestCreateLabel(Assert assert)
        {
            assert.Expect(6);

            var view = Test.GetView();

            var label = view.CreateLabelElement("someLabel", "Title", "10px", true, HTMLColor.Blue);
            assert.Ok(label != null, "label created");

            view.Root.AppendChild(label);
            var foundLabel = Document.GetElementById<LabelElement>("someLabel");

            assert.Ok(foundLabel != null, "foundLabel");
            assert.DeepEqual(foundLabel.InnerHTML, "Title", "foundLabel.innerHtml = 'Title'");
            assert.DeepEqual(foundLabel.Style.Color, HTMLColor.Blue, "foundLabel.Style.Color = Blue");
            assert.DeepEqual(foundLabel.Style.Margin, "10px", "foundLabel.Style.Margin = '10px'");
            assert.DeepEqual(foundLabel.Style.FontWeight, "bold", "foundLabel.Style.FontWeight = 'bold'");
        }
开发者ID:modulexcite,项目名称:Samples-4,代码行数:18,代码来源:Test.cs

示例9: Test

        public static void Test(Assert assert)
        {
            assert.Expect(8);

            // TEST
            var words = new string[] { "ab2", "ac", "a", "ab12", "", "ab", "bac", "z" };
            var sortedWords = (from word in words
                               orderby word
                               select word).ToArray();
            assert.DeepEqual(sortedWords, new[] { "", "a", "ab", "ab12", "ab2", "ac", "bac", "z" }, "Order by words");

            // TEST
            var sortedWordsByLength = (from word in words
                                       orderby word.Length
                                       select word).ToArray();
            assert.DeepEqual(sortedWordsByLength, new[] { "", "a", "z", "ac", "ab", "ab2", "bac", "ab12" }, "Order by word length");

            // TEST
            var sortedPersonsByName = (from p in Person.GetPersons()
                                       orderby p.Name
                                       select p.Name).ToArray();
            assert.DeepEqual(sortedPersonsByName, new[] { "Billy", "Dora", "Frank", "Ian", "John", "Mary", "Nemo", "Zeppa" }, "Order by person names");

            // TODO test with System.StringComparison

            // TEST
            var doubles = new double[] { 1.0, -0.7, 2.1, 0.9, 1.4, 2.9 };
            var sortedDoubles = (from d in doubles
                                 orderby d descending
                                 select d).ToArray();
            assert.DeepEqual(sortedDoubles, new[] { 2.9, 2.1, 1.4, 1.0, 0.9, -0.7 }, "Order by descending double");

            // TEST
            var sortedPersonsByCountDesc = (from p in Person.GetPersons()
                                            orderby p.Count descending
                                            select p.Count).ToArray();
            assert.DeepEqual(sortedPersonsByCountDesc, new[] { 3000, 700, 700, 550, 500, 300, 100, 50 }, "Order by person count descending");

            // TEST
            var sortedWordsByLengthAndLetters = (from word in words
                                                 orderby word.Length, word
                                                 select word).ToArray();
            assert.DeepEqual(sortedWordsByLengthAndLetters, new[] { "", "a", "z", "ab", "ac", "ab2", "bac", "ab12" }, "Order by word length then by letters");

            // TEST
            var sortedWordsByLengthAndLettersLambda = words.OrderBy(x => x.Length).ThenByDescending(x => x).ToArray();
            assert.DeepEqual(sortedWordsByLengthAndLettersLambda, new[] { "", "z", "a", "ac", "ab", "bac", "ab2", "ab12" }, "Order by word length then by letters as lambda");

            // TEST
            // var numbers = new[] { 2, 4, 6, 1, 5, 7, 9, 0, 8, 3};
            var numbers = new[] { 2, 4, 6, 1, 5 };
            var numbersReversed = numbers.Reverse<int>().ToArray();
            assert.DeepEqual(numbersReversed, new[] { 5, 1, 6, 4, 2 }, "Reverse() numbers");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:54,代码来源:TestLinqOrderingOperators.cs

示例10: TestUseCase

        public static void TestUseCase(Assert assert)
        {
            assert.Expect(1);

            var s = "ab|abc&ab&abc|de&ef&";

            var r = s.Split('|', '&');
            var expected = new[] { "ab", "abc", "ab", "abc", "de", "ef", "" };

            assert.DeepEqual(r, expected, "#578 Split(params char[] separator)");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:11,代码来源:N578.cs

示例11: TestCreatePersonUIElements

        private static void TestCreatePersonUIElements(Assert assert)
        {
            assert.Expect(2);

            var application = Test.GetApplication();

            application.RenderPerson();

            var lblPersonName = Document.GetElementById<LabelElement>("lblPersonName");
            assert.Ok(lblPersonName != null, "lblPersonName created");
            assert.DeepEqual(lblPersonName.InnerHTML, "Frank", "lblPersonName = 'Frank'");
        }
开发者ID:modulexcite,项目名称:Samples-4,代码行数:12,代码来源:Test.cs

示例12: CaughtExceptions

        public static void CaughtExceptions(Assert assert)
        {
            assert.Expect(3);

            TryCatchWithCaughtException();
            assert.Ok(true, "Exception catch");

            TryCatchWithCaughtTypedException();
            assert.Ok(true, "Typed exception catch");

            var exceptionMessage = TryCatchWithCaughtArgumentException();
            assert.DeepEqual(exceptionMessage, "catch me", "Typed exception catch with exception message");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:13,代码来源:TestTryCatchBlocks.cs

示例13: Bridge329

        public static void Bridge329(Assert assert)
        {
            assert.Expect(5);

            DateTime d1;
            var b1 = DateTime.TryParse("2001-01-01", out d1, true);
            assert.Ok(b1, "TryParse parsed '2001 - 01 - 01'");
            assert.Equal(d1.GetUtcFullYear(), 2001, "TryParse works Year");
            assert.Equal(d1.GetUtcMonth(), 1, "TryParse works Month");
            assert.Equal(d1.GetUtcDay(), 1, "TryParse works Day");

            var d2 = DateTime.Parse("2001-01-01", true);
            assert.DeepEqual(d2.ToString(), d1.ToString(), "TryParse And Parse give the same result");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:14,代码来源:TestDateFunctions.cs

示例14: DateTimes

        // DateTime functions
        public static void DateTimes(Assert assert)
        {
            assert.Expect(2);

            // TEST
            // [#83] by C#
            var str = "2015-03-24T10:48:09.1500225+03:00";
            var bridgeDate = DateTime.Parse(str);
            var bridgeDate1 = new DateTime(str);

            assert.DeepEqual(bridgeDate, bridgeDate1, "[#83] C# bridgeDate = bridgeDate1");

            // TEST
            // [#83] by JavaScript code. This is to check the same issue as above and just to check another way of calling QUnit from JavaScript
            Script.Write<dynamic>(@"var str = ""2015-03-24T10:48:09.1500225+03:00"",
            bridgeDate = Bridge.Date.parse(str),
            jsDate = new Date(Date.parse(str)),
            format = ""yyyy-MM-dd hh:mm:ss"";
            assert.deepEqual(Bridge.Date.format(bridgeDate, format), Bridge.Date.format(jsDate, format), ""[#83] js"")");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:21,代码来源:TestDateFunctions.cs

示例15: Test

        public static void Test(Assert assert)
        {
            assert.Expect(8);

            // TEST
            var numbers = new[] { 1, 3, 5, 7, 9 };
            var firstTwo = numbers.Take(2).ToArray();
            assert.DeepEqual(firstTwo, new[] { 1, 3 }, "Take() the first two array elements");

            // TEST
            var lastThree = numbers.TakeFromLast(3).ToArray();
            assert.DeepEqual(lastThree, new[] { 5, 7, 9 }, "TakeFromLast() the last three array elements");

            // TEST
            var exceptTwoLast = numbers.TakeExceptLast(2).ToArray();
            assert.DeepEqual(exceptTwoLast, new[] { 1, 3, 5 }, "TakeExceptLast() the first array elements except the last two");

            // TEST
            var takeWhileLessTwo = numbers.TakeWhile((number) => number < 2).ToArray();
            assert.DeepEqual(takeWhileLessTwo, new[] { 1 }, "TakeWhile() less two");

            // TEST
            var takeWhileSome = numbers.TakeWhile((number, index) => number - index <= 4).ToArray();
            assert.DeepEqual(takeWhileSome, new[] { 1, 3, 5, 7 }, "TakeWhile() by value and index");

            // TEST
            var skipThree = numbers.Skip(3).ToArray();
            assert.DeepEqual(skipThree, new[] { 7, 9 }, "Skip() the first three");

            // TEST
            var skipWhileLessNine = numbers.SkipWhile(number => number < 9).ToArray();
            assert.DeepEqual(skipWhileLessNine, new[] { 9 }, "SkipWhile() less then 9");

            // TEST
            var skipWhileSome = numbers.SkipWhile((number, index) => number <= 3 && index < 2).ToArray();
            assert.DeepEqual(skipWhileSome, new[] { 5, 7, 9 }, "SkipWhile() by value and index");
        }
开发者ID:txdv,项目名称:Testing,代码行数:37,代码来源:TestLinqPartitioningOperators.cs


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