Example #1
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 #2
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 #3
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 #4
0
        public void StringContainsInOrder_ValueNull_Fail()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;
            MWTAssert.StringContainsInOrder(null, new string[] { "token1", "token3", "token2" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <null>, source string can not be null.",
                                    mockAssert.LastMessage);
        }
Example #5
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 #6
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 #7
0
        public void StringContainsInOrder_OneSubstring_Pass()
        {
            MockAssertResultHandler mockAssert = new MockAssertResultHandler();

            ServiceLocator.AssertResultHandler = mockAssert;

            // at the very begining of the string
            MWTAssert.StringContainsInOrder("foobar", new string[] { "foo" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <foobar>, contains multi substrings in correct order: <foo>!",
                                    mockAssert.LastMessage);

            // at the very end of the string
            MWTAssert.StringContainsInOrder("barfoo", new string[] { "foo" });
            UnitTestAssert.AreEqual("Assert.StringContainsInOrder: Value: <barfoo>, contains multi substrings in correct order: <foo>!",
                                    mockAssert.LastMessage);
        }