• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# QUnit.Assert类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Assert类属于Bridge.QUnit命名空间,在下文中一共展示了Assert类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

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


示例2: ThrownExceptions

        public static void ThrownExceptions(Assert assert)
        {
            assert.Expect(12);

            // #230
            assert.Throws(TryCatchWithNotCaughtTypedException, "catch me", "A.Typed exception is not Caught");
            assert.Ok(IsATry, "A. exception not caught - try section called");
            assert.Ok(!IsACatch, "A. exception not caught - catch section not called");

            // #229
            assert.Throws(TryCatchWithNotCaughtTypedExceptionAndArgument, "catch me", "[#229] B. Typed exception is not Caught; and argument");
            assert.Ok(IsBTry, "[#229] B. exception not caught - try section called");
            assert.Ok(!IsBCatch, "B. exception not caught - catch section not called");

            // #231
            assert.Throws(TryCatchWithRethrow, "catch me", "[#231] C. Rethrow");
            assert.Ok(IsCTry, "C. exception caught and re-thrown - try section called");
            assert.Ok(IsCCatch, "C. exception caught and re-thrown - catch section called");

            assert.Throws(TryCatchWithRethrowEx, new Func<object, bool>((error) =>
            {
                return error.ToString() == "catch me";
            }), "D. Rethrow with parameter");
            assert.Ok(IsDTry, "D. exception caught and re-thrown  - try section called");
            assert.Ok(IsDCatch, "D. exception caught and re-thrown  - catch section called");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:26,代码来源:TestTryCatchBlocks.cs


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


示例4: TestUseCase

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

            Func<object> item11 = () => 11;
            assert.Equal(item11.IsNullOrUndefined(), false, "Bridge655 IsNullOrUndefined11");
            assert.Equal(item11(), 11, "Bridge655 item11");

            Func<int, int> item12 = (i) => i;
            assert.Equal(item12.IsNullOrUndefined(), false, "Bridge655 IsNullOrUndefined12");
            assert.Equal(item12(12), 12, "Bridge655 item12");

            Func<object> item21 = () => 21;
            assert.Equal(item21.IsNullOrUndefined(21), false, "Bridge655 IsNullOrUndefined21 false");
            assert.Equal(item21.IsNullOrUndefined(0), true, "Bridge655 IsNullOrUndefined21 true");
            assert.Equal(item21(), 21, "Bridge655 item21");

            Func<int, string, int> item22 = (i, s) => i + s.Length;
            assert.Equal(item22.IsNullOrUndefined("22"), "false", "Bridge655 IsNullOrUndefined22 false");
            assert.Equal(item22.IsNullOrUndefined(string.Empty), "true", "Bridge655 IsNullOrUndefined22 true");
            assert.Equal(item22(19, "two"), 22, "Bridge655 item22");

            Action<int, string> item32 = (i, s) => { var b = i == s.Length; };
            assert.Equal(item32.IsNullOrUndefined("32"), "false", "Bridge655 IsNullOrUndefined32 false");
            assert.Equal(item32.IsNullOrUndefined(string.Empty), "true", "Bridge655 IsNullOrUndefined32 true");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:26,代码来源:N655.cs


示例5: TestUseCase

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

            var s1 = string.Join(",", new[] { "a", "b" });
            assert.Equal(s1, "a,b", "Join1");

            var animals = new List<Animal>();
            animals.Add(new Animal("Squirrel", "Rodent"));
            animals.Add(new Animal("Gray Wolf", "Carnivora"));
            animals.Add(new Animal("Capybara", "Rodent"));

            string s2 = String.Join(" ", animals);
            assert.Equal(s2, "Squirrel Gray Wolf Capybara", "Join2");

            object[] values = { null, "Cobb", 4189, 11434, .366 };
            string s31 = String.Join("|", values);
            assert.Equal(s31, "|Cobb|4189|11434|0.366", "Join31");

            values[0] = String.Empty;
            string s32 = String.Join("|", values);
            assert.Equal(s32, "|Cobb|4189|11434|0.366", "Join32");

            string[] sArr = new string[10];
            for (int i = 0; i < 10; i++)
                sArr[i] = String.Format("{0,-3}", i * 5);

            string s4 = String.Join(":", sArr);
            assert.Equal(s4, "0  :5  :10 :15 :20 :25 :30 :35 :40 :45 ", "Join4");

            var val = new string[] { "apple", "orange", "grape", "pear" };
            var s5 = string.Join(", ", val, 1, 2);
            assert.Equal(s5, "orange, grape", "Join5");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:34,代码来源:N381.cs


示例6: TestUseCase

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

            var ted = new Bridge566B();
            assert.Equal(ted.Data, "Ted", "#566 Ted");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:7,代码来源:N566.cs


示例7: TestUseCase

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

            object o = Script.Undefined;
            assert.Throws(() => { var s = (string)o; }, "Unable to cast type 'null' to type String");
        }
开发者ID:suyongquan88,项目名称:Bridge,代码行数:7,代码来源:N674.cs


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


示例9: TestStatic

        public static void TestStatic(Assert assert)
        {
            assert.Expect(16);

            assert.Equal(Static.Foo(1), "Foo(int x)", "Static Foo(int x)");
            assert.Equal(Static.Foo("string"), "Foo(string s)", "Static Foo(string s)");
            assert.Equal(Static.Foo(1.1), "Foo(double d)", "Static Foo(double d)");
            assert.Equal(Static.Foo(1, 2), "Foo(int x, int y)", "Static Foo(int x, int y)");
            assert.Equal(Static.Foo(1, 1.1), "Foo(int x, double y)", "Static Foo(int x, double y)");
            assert.Equal(Static.Foo(1.1, 1), "Foo(double x, int y)", "Static Foo(double x, int y)");

            assert.Equal(Static.FooReturnType(1), 'C', "Static char FooReturnType(int y)");
            assert.Equal(Static.FooReturnType(1.1), "string FooReturnType(double d)", "Static string FooReturnType(double d)");

            assert.Equal(Static.FooOptionalParameters(1), "FooOptionalParameters(int x)", "Static FooOptionalParameters(int x)");
            assert.Equal(Static.FooOptionalParameters(1, 2), "FooOptionalParameters(int x, int y = 5)", "Static FooOptionalParameters(int x, int y = 5)");

            assert.Equal(Static.FooMultipleOptionalParameters(1, 2), "FooMultipleOptionalParameters(int x, int y = 5)", "Static FooMultipleOptionalParameters(int x, int y = 5)");
            assert.Equal(Static.FooMultipleOptionalParameters(1, z: 2), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Static FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(Static.FooMultipleOptionalParameters(1, 2, 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Static FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(Static.FooMultipleOptionalParameters(1, z: 2, y: 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Static FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");

            assert.Equal(Static.FooNamedArgument(x: 1), "FooNamedArgument(int x)", "Static FooNamedArgument(int x)");
            assert.Equal(Static.FooNamedArgument(d: 1), "FooNamedArgument(double d)", "Static FooNamedArgument(double d)");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:25,代码来源:TestOverloadStaticMethods.cs


示例10: TesForeach

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

            string[] keys = new[] { "1", "2", "3" };
            Action[] handlers = new Action[3];
            int i = 0;
            string result = "";

            foreach (var itm in keys)
                handlers[i++] = () => result += itm;

            foreach (var handler in handlers)
            {
                handler();
            }

            assert.Equal(result, "123", "Bridge563 No block foreach loop");

            i = 0;
            result = "";

            foreach (var itm in keys)
            {
                handlers[i++] = () => result += itm;
            }

            foreach (var handler in handlers)
            {
                handler();
            }

            assert.Equal(result, "123", "Bridge563 block foreach loop");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:34,代码来源:N563.cs


示例11: TestUseCase

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

            int[] numbers = { 1, 2, 3 };

            int sum = 0;

            foreach (int a in numbers)
            {
                sum = sum + a;
            }

            foreach (int a in numbers)
            {
                sum = sum + a;
            }

            foreach (int a in numbers)
            {
                sum = sum + a;
            }

            foreach (int a in numbers)
            {
                sum = sum + a;
            }

            assert.Equal(sum, 24, "Bridge502 sum");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:30,代码来源:N502.cs


示例12: TestCloneCompare

        public static void TestCloneCompare(Assert assert)
        {
            assert.Expect(13);

            var v1 = new Version(1, 2, 3, (4 << 16) + 5);

            var o = v1.Clone();
            assert.Ok(o != null, "v1 Cloned");

            var v2 = o as Version;
            assert.Ok(v2 != null, "v1 Cloned as Version");

            assert.Equal(v2.Major, 1, "v2.Major 1");
            assert.Equal(v2.Minor, 2, "v2.Minor 2");
            assert.Equal(v2.Build, 3, "v2.Build 3");
            assert.Equal(v2.Revision, 262149, "v2.Revision  (4 << 16) + 5 = 262149");
            assert.Equal(v2.MajorRevision, 4, "v2.MajorRevision 4");
            assert.Equal(v2.MinorRevision, 5, "v2.MinorRevision 5");

            var v3 = new Version(1, 2, 2, (4 << 16) + 5);
            assert.Equal(v1.CompareTo(v3), 1, "v1.CompareTo(v3)");

            var v4 = new Version(1, 3, 3, (4 << 16) + 5);
            assert.Equal(v1.CompareTo(v4), -1, "v1.CompareTo(v4)");

            assert.Equal(v1.CompareTo(o), 0, "v1.CompareTo(o)");
            assert.Equal(v1.CompareTo(v2), 0, "v1.CompareTo(v2)");
            assert.NotEqual(v1.CompareTo(null), 0, "v1.CompareTo(null)");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:29,代码来源:TestVersion.cs


示例13: TestUseCase

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

            SByte i8_1 = -2;
            SByte i8_2 = (SByte)(i8_1 >> 4);
            Byte u8_1 = 0xFE;
            Byte u8_2 = (Byte)(u8_1 >> 4);

            Int16 i16_1 = -2;
            Int16 i16_2 = (Int16)(i16_1 >> 8);
            UInt16 u16_1 = 0xFFFE;
            UInt16 u16_2 = (UInt16)(u16_1 >> 8);

            Int32 i32_1 = -2;
            Int32 i32_2 = i32_1 >> 16;
            UInt32 u32_1 = 0xFFFFFFFE;
            UInt32 u32_2 = u32_1 >> 16;

            assert.Equal(i8_2, -1, "Bridge592 i8_2");
            assert.Equal(u8_2, 0xF, "Bridge592 u8_2");
            assert.Equal(i16_2, -1, "Bridge592 i16_2");
            assert.Equal(u16_2, 0xFF, "Bridge592 u16_2");
            assert.Equal(i32_2, -1, "Bridge592 i32_2");
            assert.Equal(u32_2, 0xFFFF, "Bridge592 u32_2");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:26,代码来源:N592.cs


示例14: TestUseCase

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

            var t1 = new Type();
            assert.Ok(t1 != null, "#565 t1");

            var t2 = new ValueType();
            assert.Ok(t2 != null, "#565 t2");

            var t3 = new IntPtr();
            assert.Ok(t3.GetType() == typeof(IntPtr) , "#565 t3");

            var t4 = new UIntPtr();
            assert.Ok(t4.GetType() == typeof(UIntPtr), "#565 t4");

            var t5 = new ParamArrayAttribute();
            assert.Ok(t5 != null, "#565 t5");

            var t6 = new RuntimeTypeHandle();
            assert.Ok(t6.GetType() == typeof(RuntimeTypeHandle), "#565 t6");

            var t7 = new RuntimeFieldHandle();
            assert.Ok(t7.GetType() == typeof(RuntimeFieldHandle), "#565 t7");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:25,代码来源:N565.cs


示例15: TestUseCase

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

            var o = JSON.Parse<bool>("true");
            assert.Equal(o, true, "Bridge544 bool");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:7,代码来源:N544.cs


示例16: TestUseCase

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

            var array1 = new Int8Array(1);
            Bridge550.TestMethod(array1, "Int8Array", assert);

            var array2 = new Uint8Array(1);
            Bridge550.TestMethod(array2, "Uint8Array", assert);

            var array3 = new Uint8ClampedArray(1);
            Bridge550.TestMethod(array3, "Uint8ClampedArray", assert);

            var array4 = new Int16Array(1);
            Bridge550.TestMethod(array4, "Int16Array", assert);

            var array5 = new Uint16Array(1);
            Bridge550.TestMethod(array5, "Uint16Array", assert);

            var array6 = new Int32Array(1);
            Bridge550.TestMethod(array6, "Int32Array", assert);

            var array7 = new Uint32Array(1);
            Bridge550.TestMethod(array7, "Uint32Array", assert);

            var array8 = new Float32Array(1);
            Bridge550.TestMethod(array8, "Float32Array", assert);

            var array9 = new Float64Array(1);
            Bridge550.TestMethod(array9, "Float64Array", assert);

            var array10 = new DataView(array9.Buffer);
            Bridge550.TestMethod(array10, "DataView", assert);
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:34,代码来源:N550.cs


示例17: TestInstance

        public static void TestInstance(Assert assert)
        {
            assert.Expect(17);

            var i = new Instance();

            assert.Ok(i != null, "i created");
            assert.Equal(i.Foo(1), "Foo(int x)", "Instance Foo(int x)");
            assert.Equal(i.Foo("string"), "Foo(string s)", "Instance Foo(string s)");
            assert.Equal(i.Foo(1.1), "Foo(double d)", "Instance Foo(double d)");
            assert.Equal(i.Foo(1, 2), "Foo(int x, int y)", "Instance Foo(int x, int y)");
            assert.Equal(i.Foo(1, 1.1), "Foo(int x, double y)", "Instance Foo(int x, double y)");
            assert.Equal(i.Foo(1.1, 1), "Foo(double x, int y)", "Instance Foo(double x, int y)");

            assert.Equal(i.FooReturnType(1), 'C', "Instance char FooReturnType(int y)");
            assert.Equal(i.FooReturnType(1.1), "string FooReturnType(double d)", "Instance string FooReturnType(double d)");

            assert.Equal(i.FooOptionalParameters(1), "FooOptionalParameters(int x)", "Instance FooOptionalParameters(int x)");
            assert.Equal(i.FooOptionalParameters(1, 2), "FooOptionalParameters(int x, int y = 5)", "Instance FooOptionalParameters(int x, int y = 5)");

            assert.Equal(i.FooMultipleOptionalParameters(1, 2), "FooMultipleOptionalParameters(int x, int y = 5)", "Instance FooMultipleOptionalParameters(int x, int y = 5)");
            assert.Equal(i.FooMultipleOptionalParameters(1, z: 2), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(i.FooMultipleOptionalParameters(1, 2, 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(i.FooMultipleOptionalParameters(1, z: 2, y: 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");

            assert.Equal(i.FooNamedArgument(x: 1), "FooNamedArgument(int x)", "Static FooNamedArgument(int x)");
            assert.Equal(i.FooNamedArgument(d: 1), "FooNamedArgument(double d)", "Static FooNamedArgument(double d)");
        }
开发者ID:txdv,项目名称:Testing,代码行数:28,代码来源:TestOverloadInstanceMethods.cs


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


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


示例20: TestConstructors

        public static void TestConstructors(Assert assert)
        {
            assert.Expect(42);

            var v1 = new Version();

            assert.Ok(v1 != null, "v1 created");
            assert.Equal(v1.Major, 0, "v1.Major 0");
            assert.Equal(v1.Minor, 0, "v1.Minor 0");
            assert.Equal(v1.Build, -1, "v1.Build -1");
            assert.Equal(v1.Revision, -1, "v1.Revision -1");
            assert.Equal(v1.MajorRevision, -1, "v1.MajorRevision -1");
            assert.Equal(v1.MinorRevision, -1, "v1.MinorRevision -1");

            var v2 = new Version("2.4.1128.2");
            assert.Ok(v2 != null, "v2 created");
            assert.Equal(v2.Major, 2, "v2.Major 2");
            assert.Equal(v2.Minor, 4, "v2.Minor 4");
            assert.Equal(v2.Build, 1128, "v2.Build 1128");
            assert.Equal(v2.Revision, 2, "v2.Revision 2");
            assert.Equal(v2.MajorRevision, 0, "v2.MajorRevision 0");
            assert.Equal(v2.MinorRevision, 2, "v2.MinorRevision 2");

            var v3 = new Version("2.4.1128.65537");
            assert.Ok(v3 != null, "v3 created");
            assert.Equal(v3.Major, 2, "v3.Major 2");
            assert.Equal(v3.Minor, 4, "v3.Minor 4");
            assert.Equal(v3.Build, 1128, "v3.Build 1128");
            assert.Equal(v3.Revision, 65537, "v3.Revision 65537");
            assert.Equal(v3.MajorRevision, 1, "v3.MajorRevision 1");
            assert.Equal(v3.MinorRevision, 1, "v3.MinorRevision 1");

            var v4 = new Version(20, 10);
            assert.Ok(v4 != null, "v4 created");
            assert.Equal(v4.Major, 20, "v4.Major 20");
            assert.Equal(v4.Minor, 10, "v4.Minor 10");
            assert.Equal(v4.Build, -1, "v4.Build -1");
            assert.Equal(v4.Revision, -1, "v4.Revision -1");
            assert.Equal(v4.MajorRevision, -1, "v4.MajorRevision -1");
            assert.Equal(v4.MinorRevision, -1, "v4.MinorRevision -1");

            var v5 = new Version(200, 100, 300);
            assert.Ok(v5 != null, "v5 created");
            assert.Equal(v5.Major, 200, "v5.Major 200");
            assert.Equal(v5.Minor, 100, "v5.Minor 100");
            assert.Equal(v5.Build, 300, "v5.Build 300");
            assert.Equal(v5.Revision, -1, "v5.Revision -1");
            assert.Equal(v5.MajorRevision, -1, "v5.MajorRevision -1");
            assert.Equal(v5.MinorRevision, -1, "v5.MinorRevision -1");

            var v6 = new Version(2000, 1000, 3000, (345 << 16) + 4000);
            assert.Ok(v6 != null, "v6 created");
            assert.Equal(v6.Major, 2000, "v6.Major 2000");
            assert.Equal(v6.Minor, 1000, "v6.Minor 1000");
            assert.Equal(v6.Build, 3000, "v6.Build 3000");
            assert.Equal(v6.Revision, 22613920, "v6.Revision (345 << 16) + 4000 = 22613920");
            assert.Equal(v6.MajorRevision, 345, "v6.MajorRevision 345");
            assert.Equal(v6.MinorRevision, 4000, "v6.MinorRevision 4");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:59,代码来源:TestVersion.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BrightIdeasSoftware.ModelDropEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# Html5.Element类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap