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


C# Assert.Ok方法代码示例

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


在下文中一共展示了Assert.Ok方法的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(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

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

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

示例5: TestUseCase

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

            var s = new Bridge608A("test");
            object o = "test";
            assert.Ok(s.Equals(o), "Bridge608 Object");
            assert.Ok(s.Equals("test"), "Bridge608 String");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:9,代码来源:N608.cs

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

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

示例8: TestBC

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

            A b = new B();

            assert.Ok(b != null, "Instance of B created as instance of A");
            assert.Equal(b.GetString(), "B", "b.GetString() = 'B'");
            assert.Equal(b.Data, 1, "b.Data = 1");

            A c = new C();
            assert.Ok(c != null, "Instance of C created as instance of A");
            assert.Equal(c.GetString(), "C", "c.GetString() = 'C'");
            assert.Equal(c.Data, -1, "c.Data = -1");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:15,代码来源:TestAbstractClass.cs

示例9: TestInterfaceMethodAndProperty

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

            ISimple a = new A();

            assert.Ok(a != null, "Instance of A created through ISimple interface");
            assert.Equal(a.GetString(), "A.ISimple", "a.GetString() = A.ISimple  through interface");
            assert.Equal(a.Data, 1, "a.Data = 1  through interface");

            var b = a as A;
            assert.Ok(b != null, "Instance of ISimple as A");
            assert.Equal(a.GetString(), "A.ISimple", "a.GetString() = A.ISimple through instance");
            assert.Equal(a.Data, 1, "a.Data = 1 through instance");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:15,代码来源:TestInterfaces.cs

示例10: Bridge349

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

            DateTime date;
            var culture = new CultureInfo("ru-RU");

            assert.Ok(culture != null, "Created CultureInfo(\"ru-RU\")");

            var parsed = DateTime.TryParse("22.08.2015", culture, out date);
            assert.Ok(parsed, "Parsed \"22.08.2015\"");
            assert.Equal(date.Year, 2015, "TryParse works Year");
            assert.Equal(date.Month, 8, "TryParse works Month");
            assert.Equal(date.Day, 22, "TryParse works Day");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:15,代码来源:TestDateFunctions.cs

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

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

示例13: TestExplicitInterfaceMethodAndProperty

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

            ISimple b = new B();
            assert.Ok(b != null, "Instance of B created through ISimple interface explicitly");
            assert.Equal(b.GetString(), "explicit B.ISimple", "b.GetString() = explicit B.ISimple");
            assert.Equal(b.Data, 2, "a.Data = 2");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:9,代码来源:TestInterfaces.cs

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

示例15: TestC

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

            var c = new C();

            assert.Ok(c != null, "Instance of C created");
            assert.Equal(c.GetString(), "C", "c.GetString() = 'C'");
            assert.Equal(c.Data, -1, "c.Data = -1");
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:10,代码来源:TestAbstractClass.cs


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