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");
        }
Example #2
27
        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");
        }
Example #3
0
        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)");
        }
Example #4
0
        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");
        }
Example #5
0
        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");
        }
Example #6
0
        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");
        }
Example #7
0
        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");
        }
Example #8
0
        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");
        }
Example #9
0
        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");
        }
Example #10
0
        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");
        }
        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)");
        }
Example #12
0
        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");
        }
Example #13
0
        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");
        }
Example #14
0
        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'");
        }
Example #15
0
        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");
        }
Example #16
0
        public static void TestB(Assert assert)
        {
            assert.Expect(3);

            var b = new B();

            assert.Ok(b != null, "Instance of B created");
            assert.Equal(b.GetString(), "B", "b.GetString() = 'B'");
            assert.Equal(b.Data, 1, "b.Data = 1");
        }
Example #17
0
        public static void TestA(Assert assert)
        {
            assert.Expect(4);

            var a = new A(10);

            assert.Ok(a != null, "Instance of A created");
            assert.Equal(a.X, 10, "a.X = 10");
            assert.Equal(a.HandleNumber(100), 100, "a.HandleNumber(100) = 100");
            assert.Equal(a.HandleString("Hundred"), "Hundred", "a.HandleString('Hundred') = 'Hundred'");
        }
Example #18
0
        public static void TestB(Assert assert)
        {
            assert.Expect(7);

            var a = new A();

            assert.Ok(a != null, "Instance of A created");
            assert.Equal(a.Test(), "A", "a.Test() = 'A'");

            var b = new B();

            assert.Ok(b != null, "Instance of B created");
            assert.Equal(b.Test(), "B", "b.Test() = 'B'");
            assert.Equal(b.TestA(), "A", "b.TestA() = 'A'");

            A c = new B();

            assert.Ok(c != null, "Instance of C created");
            assert.Equal(c.Test(), "B", "c.Test() = 'B'");
        }
Example #19
0
        public static void TestSubtractTimeSpan(Assert assert)
        {
            assert.Expect(4);

            DateTime date1 = new DateTime(DateTime.Utc(1996, 6, 3, 22, 15, 0));
            DateTime date2 = new DateTime(DateTime.Utc(1996, 12, 6, 13, 2, 0));
            DateTime date3 = new DateTime(DateTime.Utc(1996, 10, 12, 8, 42, 0));

            TimeSpan diff1 = date2.Subtract(date1);
            assert.Ok(diff1.Equals(new TimeSpan(185, 14, 47, 0)), "Bridge582 TestSubtractTimeSpan diff1");

            DateTime date4 = date3.Subtract(diff1);
            assert.Ok(date4.Equals(new DateTime(DateTime.Utc(1996, 4, 9, 17, 55, 0))), "Bridge582 TestSubtractTimeSpan date4");

            TimeSpan diff2 = date2 - date3;
            assert.Ok(diff2.Equals(new TimeSpan(55, 4, 20, 0)), "Bridge582 TestSubtractTimeSpan diff2");

            DateTime date5 = date1 - diff2;
            assert.Ok(date5.Equals(new DateTime(DateTime.Utc(1996, 4, 9, 17, 55, 0))), "Bridge582 TestSubtractTimeSpan date5");
        }
Example #20
0
        public static void TestAB(Assert assert)
        {
            assert.Expect(4);

            A b = new B(10, 20);

            assert.Ok(b != null, "Instance of B created as A type");
            assert.Equal(b.X, 10, "b.X = 10");
            assert.Equal(b.HandleNumber(10), 10, "b.HandleNumber(10) = 10");
            assert.Equal(b.HandleString("Hundred"), "Hundred", "b.HandleString('Hundred') = 'Hundred'");
        }
Example #21
0
        public static void TestB(Assert assert)
        {
            assert.Expect(5);

            var b = new B(10, 20);

            assert.Ok(b != null, "Instance of B created");
            assert.Equal(b.X, 10, "b.X = 10");
            assert.Equal(b.Y, 20, "b.Y = 20");
            assert.Equal(b.HandleNumber(1), 100, "b.HandleNumber(1) = 100");
            assert.Equal(b.HandleString("Hundred"), "Hundred", "b.HandleString('Hundred') = 'Hundred'");
        }
Example #22
0
        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'");
        }
Example #23
0
        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");
        }
        public static void IssueBridge393(Assert assert)
        {
            assert.Expect(2);

            string a = "testa";
            string b = "testa";

            bool result = a.Equals(b, StringComparison.InvariantCultureIgnoreCase);

            assert.Ok(result, "testa testa StringComparison.InvariantCultureIgnoreCase");

            string a1 = "testa";
            string b1 = "testb";

            bool result1 = a1.Equals(b1, StringComparison.InvariantCultureIgnoreCase);

            assert.NotOk(result1, "testa testb StringComparison.InvariantCultureIgnoreCase");
        }
Example #25
0
        public static void TestTwoInterfaces(Assert assert)
        {
            assert.Expect(9);

            var c = new C();

            assert.Ok(c != null, "Instance of C created through ISimpleAsWell interface");
            assert.Equal(c.GetStringAsWell(), "C.ISimpleAsWell", "a.GetStringAsWell() = A.ISimple through instance");
            assert.Equal(c.DataAsWell, 4, "c.DataAsWell = 4  through instance");

            var a = c as ISimple;
            assert.Ok(a != null, "Instance of ISimple as C");
            assert.Equal(a.GetString(), "C.ISimple", "a.GetString() = C.ISimple  through interface");
            assert.Equal(a.Data, 3, "a.Data = 3 through interface");

            var b = c as ISimpleAsWell;
            assert.Ok(b != null, "Instance of ISimpleAsWell as C");
            assert.Equal(b.GetStringAsWell(), "C.ISimpleAsWell", "b.GetStringAsWell() = C.ISimpleAsWell  through interface");
            assert.Equal(b.DataAsWell, 4, "b.DataAsWell = 4 through interface");
        }
Example #26
0
        public static void Bridge320(Assert assert)
        {
            assert.Expect(1);

            string exceptionMessage = string.Empty;

            try
            {
                Script.Write("\"someString\".SomeNotExistingMethod();");
            }
            catch (Exception ex)
            {
                exceptionMessage = ex.Message;
            }

            // var expectedMessage = Utilities.BrowserHelper.IsPhantomJs()
            //    ? "undefined is not a constructor (evaluating '\"someString\".SomeNotExistingMethod()')"
            //    : "\"someString\".SomeNotExistingMethod is not a function";

            assert.Ok(exceptionMessage.Contains("SomeNotExistingMethod"), "ex.Message works on built-in JavaScript type");
        }
Example #27
0
        // Bridge[#588]
        public static void TestUseCase(Assert assert)
        {
            assert.Expect(9);

            var c2 = new C2("C2 value");
            assert.Ok(c2 != null, "Bridge588 C2");
            assert.Equal(c2.Name, "C2 value", "Bridge588 C2.Name");

            var c1 = new C1(c2);
            assert.Ok(c1 != null, "Bridge588 C1");
            assert.Equal(c1.Value.Name, "C2 value", "Bridge588 C1.Value.Name");

            assert.Ok(C1.Default != null, "Bridge588 C1.Default");
            assert.Ok(C1.Default.Value != null, "Bridge588 C1.Default.Value");
            assert.Equal(C1.Default.Value.Name, "default", "Bridge588 C1.Default.Value.Name");
            assert.Ok(C2.Default != null, "Bridge588 C2.Default");
            assert.Ok(C2.Default.Name != null, "Bridge588 C2.Default.Name");
        }
Example #28
0
        public static void TestEqualsGetHashCode(Assert assert)
        {
            assert.Expect(9);

            var v1 = new Version(100, 200, 300, (400 << 16) + 500);
            var v2 = new Version(100, 200, 300, (400 << 16) + 500);
            var v3 = new Version(101, 200, 300, (400 << 16) + 500);
            var o = new object();
            object o2 = v2;

            assert.Ok(v1.Equals(v2), "v1.Equals(v2)");
            assert.NotOk(v1.Equals(v3), "v1.Equals(v3)");
            assert.NotOk(v1.Equals(o), "v1.Equals(o)");
            assert.NotOk(v1.Equals(null), "v1.Equals(null)");
            assert.NotOk(v1.Equals(100), "v1.Equals(100)");
            assert.Ok(v1.Equals(o2), "v1.Equals(o2)");

            assert.Equal(v1.GetHashCode(), 1283637748, "v1.GetHashCode()");
            assert.Equal(v2.GetHashCode(), 1283637748, "v2.GetHashCode()");
            assert.Equal(v3.GetHashCode(), 1552073204, "v3.GetHashCode()");
        }
Example #29
0
        public static void Bridge343(Assert assert)
        {
            assert.Expect(1);

            string exceptionMessage = string.Empty;

            var i = 0;

            try
            {
                var r = 10 / i;
            }
            catch (ArgumentException)
            {
            }
            catch (Exception ex)
            {
                exceptionMessage = ex.Message;
            }

            assert.Ok(!string.IsNullOrEmpty(exceptionMessage), "Double catch block with general Exception works");
        }
Example #30
0
        public static void TestOperators(Assert assert)
        {
            assert.Expect(30);

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

            assert.Ok(v1 == v2, "v1 == v2");
            assert.NotOk(v1 != v2, "v1 != v2");
            assert.NotOk(v1 > v2, "v1 > v2");
            assert.Ok(v1 >= v2, "v1 >= v2");
            assert.NotOk(v1 < v2, "v1 < v2");
            assert.Ok(v1 <= v2, "v1 <= v2");

            assert.NotOk(v1 == v3, "v1 == v3");
            assert.Ok(v1 != v3, "v1 != v3");
            assert.NotOk(v1 > v3, "v1 > v3");
            assert.NotOk(v1 >= v3, "v1 >= v3");
            assert.Ok(v1 < v3, "v1 < v3");
            assert.Ok(v1 <= v3, "v1 <= v3");

            assert.NotOk(v1 == null, "v1 == null");
            assert.Ok(v1 != null, "v1 != null");
            assert.Ok(v1 > null, "v1 > null");
            assert.Ok(v1 >= null, "v1 >= null");
            assert.NotOk(v1 < null, "v1 < null");
            assert.NotOk(v1 <= null, "v1 <= null");

            assert.NotOk(null == v3, "null == v3");
            assert.Ok(null != v3, "null != v3");
            assert.NotOk(null > v3, "null > v3");
            assert.NotOk(null >= v3, "null >= v3");
            assert.Ok(null < v3, "null < v3");
            assert.Ok(null <= v3, "null <= v3");

            Version v4 = null;
            Version v5 = null;

            assert.Ok(v4 == v5, "v4 == v5");
            assert.NotOk(v4 != v5, "v4 != v5");
            assert.NotOk(v4 > v5, "v4 > v5");
            assert.NotOk(v4 >= v5, "v4 >= v5");
            assert.NotOk(v4 < v5, "v4 < v5");
            assert.NotOk(v4 <= v5, "v4 <= v5");
        }