Example #1
0
        public void AreNotEqual_Int_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual(1, 2, "Error Message");
            UnitTestAssert.AreEqual("Assert.AreNotEqual<System.Int32>: Not Expected <1>, Actual <2>!", mockAssert.LastMessage);
        }
Example #2
0
        public void AreNotEqual_String_PassCaseInsensitive()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual("foo", "FOO", false, "Error Message");
            UnitTestAssert.AreEqual("Assert.AreNotEqual: Not Expected <foo>, Actual <FOO>!", mockAssert.LastMessage);
        }
Example #3
0
        public void AreNotEqual_String_PassWithMessage()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual("foo", "bar", "Error Message");
            UnitTestAssert.AreEqual("Assert.AreNotEqual<System.String>: Not Expected <foo>, Actual <bar>!", mockAssert.LastMessage);
        }
Example #4
0
        public void StringStartsWith_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringStartsWith("foobar", "bar", "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #5
0
        public void AreEqual_Integers_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreEqual(1, 2, "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #6
0
        public void IsTrue_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.IsTrue(true, "Error Message");
            UnitTestAssert.AreEqual("Assert.IsTrue", mockAssert.LastMessage);
        }
Example #7
0
        public void IsTrue_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.IsTrue(false, "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #8
0
        public void AreNotEqual_Float_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual(1.0, 1.3, 0.8, "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #9
0
        public void AreEqual_String_PassIfIgnoreCase()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreEqual("foo", "FOO", true, "Error Message");
            UnitTestAssert.AreEqual("Assert.AreEqual: Expected <foo>", mockAssert.LastMessage);
        }
Example #10
0
        public void StringMatches_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringMatches("foobar", new Regex("bar"), "Error Message");
            UnitTestAssert.AreEqual("Assert.StringMatches: Value <foobar>, Expression Matched <bar>!", mockAssert.LastMessage);
        }
Example #11
0
        public void StringIsNotNullOrEmpty_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringIsNotNullOrEmpty("foobar", "Error Message");
            UnitTestAssert.AreEqual("Assert.StringIsNotNullOrEmpty: Expected: <non-null and not String.Empty>, Actual Value <String.Empty>!", mockAssert.LastMessage);
        }
Example #12
0
        public void StringDoesNotContains_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringDoesNotContain("foobar", "baz", "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("Assert.StringContains: Value <foobar>, Does Not Contain Substring <baz>!", mockAssert.LastMessage);
        }
Example #13
0
        public void StringDoesNotMatch_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringDoesNotMatch("foobar", new Regex("baz"), "Error Message");
            UnitTestAssert.AreEqual("Assert.StringDoesNotMatch: Value <foobar>, Expression That Does Not Match <baz>!", mockAssert.LastMessage);
        }
Example #14
0
        public void AreNotEqual_Float_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual((float)1.0, (float)1.9, (float)0.2, "Error Message");
            UnitTestAssert.AreEqual("Assert.AreNotEqual: Not Expected <1>, Actual <1.9>, Delta <0.2>!", mockAssert.LastMessage);
        }
Example #15
0
        public void StringContains_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains("foobar", "foo", "Error Message");
            UnitTestAssert.AreEqual("Assert.StringContains: Value <foobar>, contains Substring <foo>!", mockAssert.LastMessage);
        }
Example #16
0
        public void StringIsNullOrEmpty_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringIsNullOrEmpty("foo", "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #17
0
        public void StringMatches_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringMatches("foobar", new Regex("baz"), "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #18
0
        public void StringStartsWith_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringStartsWith("foobar", "foo", "Error Message");
            UnitTestAssert.AreEqual("Assert.StringStartsWith: Value <foobar>, Starts with <foo>!", mockAssert.LastMessage);
        }
Example #19
0
        public void StringContains_SubstringRecur_3_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains("some token1 search string token1 some antoher text token token2", "token1", 3);
            UnitTestAssert.AreEqual("Assert.StringContains: Value: <some token1 search string token1 some antoher text token token2>, contains substring: <token1> incorrect number of times. Expected number of times: <3>, Actual: <2>.",
                                    mockAssert.LastMessage);
        }
Example #20
0
        public void StringContains_SubstringRecur_Overlapping_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains("ababababa", "aba", 2);
            UnitTestAssert.AreEqual("Assert.StringContains: Value: <ababababa>, contains substring <aba> correct number of times: <2>!",
                                    mockAssert.LastMessage);
        }
Example #21
0
        public void StringContains_SubstringRecur_0_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains("some search string", "string1", 0);
            UnitTestAssert.AreEqual("Assert.StringContains: Value: <some search string>, contains substring <string1> correct number of times: <0>!",
                                    mockAssert.LastMessage);
        }
Example #22
0
        public void StringContains_SubstringEmpty_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains("some search string", "", 1);
            UnitTestAssert.AreEqual("Assert.StringContains: substring, to search for, can not be null or empty.",
                                    mockAssert.LastMessage);
        }
Example #23
0
        public void StringContainsInOrder_OneSubstring_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder("token1sometext token2 some another text token3 some text2", new string[] { "token4" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <token1sometext token2 some another text token3 some text2>, Failed at substring: <token4>, Expected multi substrings <token4>.",
                                    mockAssert.LastMessage);
        }
Example #24
0
        public void StringContainsInOrder_SeveralSubstrings_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder("token1sometext token2 some another text token3 some text2", new string[] { "token1", "token2", "token3" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <token1sometext token2 some another text token3 some text2>, contains multi substrings in correct order: <token1, token2, token3>!",
                                    mockAssert.LastMessage);
        }
Example #25
0
        public void StringContainsInOrder_NoSubstringsToSearch_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder("some string", null);
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: substrings, to search for, were not specified.",
                                    mockAssert.LastMessage);
        }
Example #26
0
        public void StringContains_ValueNull_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContains(null, "token1", 1);
            UnitTestAssert.AreEqual("Assert.StringContains: Value: <null>, source string can not be null.",
                                    mockAssert.LastMessage);
        }
Example #27
0
        public void AreNotEqual_String_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.AreNotEqual("foo", "FOO", false);
            MWTAssert.AreNotEqual("foo", "FOO", true, "This is a message '{0}'.", "foo");
            UnitTestAssert.AreEqual("This is a message 'foo'.", mockAssert.LastMessage);
        }
Example #28
0
        public void StringContainsInOrder_SeveralOverlappingSubstrings_Fail()
        {
            // Note: the logic here is that if we specified two token two times, we expect token to be in the string two times.
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder("ababab", new string[] { "aba", "abab" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <ababab>, Failed at substring: <abab>, Expected multi substrings <aba, abab>.",
                                    mockAssert.LastMessage);
        }
Example #29
0
        public void StringContainsInOrder_SeveralEqualSubstrings_Fail()
        {
            // Note: the logic here is that if we specified two token two times, we expect token to be in the string two times.
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder("token1sometext token2 some another text token3 some text2", new string[] { "token1", "token1", "token3" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <token1sometext token2 some another text token3 some text2>, Failed at substring: <token1>, Expected multi substrings <token1, token1, token3>.",
                                    mockAssert.LastMessage);
        }
Example #30
0
        public void StringIsNullOrEmpty_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            string s = null;

            MWTAssert.StringIsNullOrEmpty(s, "Error Message");
            UnitTestAssert.AreEqual("Assert.StringIsNullOrEmpty", mockAssert.LastMessage);
        }