private string GetMsg(object expected, object actual, string message, params object[] args)
            {
                AssertionFailureMessage msg = new AssertionFailureMessage(message, args);

                msg.DisplayDifferences(expected, actual, false);
                return(msg.ToString());
            }
        public void DisplayListElementsTest(string label, IList list, int index, int max, string result)
        {
            AssertionFailureMessage afm = new AssertionFailureMessage();

            afm.DisplayListElements(label, list, index, max);
            Assert.AreEqual(result, afm.ToString());
        }
        public void DisplayPositionMarker()
        {
            AssertionFailureMessage afm;

            afm = new AssertionFailureMessage();
            afm.DisplayPositionMarker(-1);
            Assert.AreEqual(String.Concat(afm.NewLine, "\t------------^"), afm.ToString());
            afm = new AssertionFailureMessage();
            afm.DisplayPositionMarker(0);
            Assert.AreEqual(String.Concat(afm.NewLine, "\t------------^"), afm.ToString());
            afm = new AssertionFailureMessage();
            afm.DisplayPositionMarker(3);
            Assert.AreEqual(String.Concat(afm.NewLine, "\t---------------^"), afm.ToString());
        }
            public void TestFormatMessageForFailNotEqualsIgnoringCase()
            {
                AssertionFailureMessage msg = new AssertionFailureMessage("message");

                msg.DisplayDifferences("Name", "NAMES", true);

                Assert.AreEqual("message" +
                                Environment.NewLine + "	String lengths differ.  Expected length=4, but was length=5." +
                                Environment.NewLine + "	Strings differ at index 4." +
                                Environment.NewLine + "	expected: <\"Name\">" +
                                Environment.NewLine + "	 but was: <\"NAMES\">" +
                                Environment.NewLine + "	----------------^" + Environment.NewLine,
                                msg.ToString());
            }
            public void DisplayListElements()
            {
                AssertionFailureMessage msg = null;

                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", new object[] { "a", "b", "c" }, 0, 3);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"a\">,<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", new object[] { "a", "b", "c" }, 0, 5);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"a\">,<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", new object[] { "a", "b", "c" }, 1, 1);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"b\">,...>" + Environment.NewLine,
                    msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", new object[] { "a", "b", "c" }, 1, 5);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", new object[0], 0, 5);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<empty>" + Environment.NewLine,
                    msg.ToString());


                msg = new AssertionFailureMessage("message");
                msg.DisplayListElements("label:", null, 0, 5);
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<null>" + Environment.NewLine,
                    msg.ToString());
            }
示例#6
0
            public void DisplayListElements()
            {
                AssertionFailureMessage msg = null;

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", new object[] { "a", "b", "c" }, 0, 3 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"a\">,<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", new object[] { "a", "b", "c" }, 0, 5 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"a\">,<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", new object[] { "a", "b", "c" }, 1, 1 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"b\">,...>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", new object[] { "a", "b", "c" }, 1, 5 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<<\"b\">,<\"c\">>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", new object[0], 0, 5 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<empty>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message");
                msg.DisplayListElements( "label:", null, 0, 5 );
                Assert.AreEqual(
                    "message" + System.Environment.NewLine +
                    "label:<null>" + Environment.NewLine,
                    msg.ToString() );
            }
        public void AddLineTest()
        {
            AssertionFailureMessage afm;

            afm = new AssertionFailureMessage();
            Assert.AreEqual(String.Empty, afm.ToString());
            afm = new AssertionFailureMessage(TestLine);
            Assert.AreEqual(TestLine, afm.ToString());
            afm = new AssertionFailureMessage("Line {0}", 1);
            Assert.AreEqual(TestLine, afm.ToString());
            afm = new AssertionFailureMessage();
            afm.AddLine(TestLine);
            Assert.AreEqual(String.Concat(afm.NewLine, TestLine), afm.ToString());
            afm = new AssertionFailureMessage();
            afm.AddLine("Line {0}", 1);
            Assert.AreEqual(String.Concat(afm.NewLine, TestLine), afm.ToString());
            afm = new AssertionFailureMessage();
            afm.AddExpectedLine(TestLine);
            Assert.AreEqual(String.Concat(afm.NewLine, "\texpected: ", TestLine), afm.ToString());
            afm = new AssertionFailureMessage();
            afm.AddActualLine(TestLine);
            Assert.AreEqual(String.Concat(afm.NewLine, "\t but was: ", TestLine), afm.ToString());
        }
        public void DisplayMethodTest()
        {
            AssertionFailureMessage afm;
            AssertionFailureMessage afm2;

            afm = new AssertionFailureMessage();
            afm.DisplayExpectedValue(TestLine);
            afm2 = new AssertionFailureMessage();
            afm2.AddExpectedLine(String.Concat("<\"", TestLine, "\">"));
            Assert.AreEqual(afm2.ToString(), afm.ToString());

            afm = new AssertionFailureMessage();
            afm.DisplayActualValue(TestLine);
            afm2 = new AssertionFailureMessage();
            afm2.AddActualLine(String.Concat("<\"", TestLine, "\">"));
            Assert.AreEqual(afm2.ToString(), afm.ToString());

            afm = new AssertionFailureMessage();
            afm.DisplayExpectedAndActual(TestLine, TestLine);
            afm2 = new AssertionFailureMessage();
            afm2.DisplayExpectedValue(TestLine);
            afm2.DisplayActualValue(TestLine);
            Assert.AreEqual(afm2.ToString(), afm.ToString());
        }
示例#9
0
 private string GetMsg( object expected, object actual, string message, params object[] args )
 {
     AssertionFailureMessage msg = new AssertionFailureMessage( message, args );
     msg.DisplayDifferences( expected, actual, false );
     return msg.ToString();
 }
示例#10
0
            public void TestFormatMessageForFailNotEqualsIgnoringCase()
            {
                AssertionFailureMessage msg = new AssertionFailureMessage( "message" );
                msg.DisplayDifferences( "Name", "NAMES", true );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "	String lengths differ.  Expected length=4, but was length=5." +
                    Environment.NewLine + "	Strings differ at index 4." +
                    Environment.NewLine + "	expected: <\"Name\">" +
                    Environment.NewLine + "	 but was: <\"NAMES\">" +
                    Environment.NewLine + "	----------------^" + Environment.NewLine,
                    msg.ToString() );
            }
示例#11
0
            public void TestFormatMessageForArraysNotEqual()
            {
                AssertionFailureMessage msg = null;

                msg = new AssertionFailureMessage( "message" );
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three" },
                    new object[] { "one", "two", "three", "four", "five" },
                    3 );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "Array lengths differ.  Expected length=3, but was length=5." +
                    Environment.NewLine + "Arrays differ at index 3." +
                    Environment.NewLine + "   extra:<<\"four\">,<\"five\">>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message" );
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three", "four", "five" },
                    new object[] { "one", "two", "three" },
                    3 );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "Array lengths differ.  Expected length=5, but was length=3." +
                    Environment.NewLine + "Arrays differ at index 3." +
                    Environment.NewLine + " missing:<<\"four\">,<\"five\">>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message" );
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three" },
                    new object[] { "one", "two", "ten" },
                    2 );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "Array lengths are both 3." +
                    Environment.NewLine + "Arrays differ at index 2." +
                    Environment.NewLine + "	String lengths differ.  Expected length=5, but was length=3." +
                    Environment.NewLine + "	Strings differ at index 1." +
                    Environment.NewLine + "	expected: <\"three\">" +
                    Environment.NewLine + "	 but was: <\"ten\">" +
                    Environment.NewLine + "	-------------^" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message" );
                msg.DisplayArrayDifferences(
                    new object[] { 1, 2, 3 },
                    new object[] { 1, 2, 10 },
                    2 );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "Array lengths are both 3." +
                    Environment.NewLine + "Arrays differ at index 2." +
                    Environment.NewLine + "	expected: <3>" +
                    Environment.NewLine + "	 but was: <10>" + Environment.NewLine,
                    msg.ToString() );

                msg = new AssertionFailureMessage( "message" );
                msg.DisplayArrayDifferences(
                    new object[,] { { 1, 2, 3 }, { 4, 5, 6 } },
                    new object[,] { { 1, 2, 9 }, { 4, 5, 6 } },
                    2 );

                Assert.AreEqual( "message" +
                    Environment.NewLine + "Array lengths are both 6." +
                    Environment.NewLine + "Arrays differ at index 2." +
                    Environment.NewLine + "	expected: <3>" +
                    Environment.NewLine + "	 but was: <9>" + Environment.NewLine,
                    msg.ToString() );
            }
            public void TestFormatMessageForArraysNotEqual()
            {
                AssertionFailureMessage msg = null;

                msg = new AssertionFailureMessage("message");
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three" },
                    new object[] { "one", "two", "three", "four", "five" },
                    3);

                Assert.AreEqual("message" +
                                Environment.NewLine + "Array lengths differ.  Expected length=3, but was length=5." +
                                Environment.NewLine + "Arrays differ at index 3." +
                                Environment.NewLine + "   extra:<<\"four\">,<\"five\">>" + Environment.NewLine,
                                msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three", "four", "five" },
                    new object[] { "one", "two", "three" },
                    3);

                Assert.AreEqual("message" +
                                Environment.NewLine + "Array lengths differ.  Expected length=5, but was length=3." +
                                Environment.NewLine + "Arrays differ at index 3." +
                                Environment.NewLine + " missing:<<\"four\">,<\"five\">>" + Environment.NewLine,
                                msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayArrayDifferences(
                    new object[] { "one", "two", "three" },
                    new object[] { "one", "two", "ten" },
                    2);

                Assert.AreEqual("message" +
                                Environment.NewLine + "Array lengths are both 3." +
                                Environment.NewLine + "Arrays differ at index 2." +
                                Environment.NewLine + "	String lengths differ.  Expected length=5, but was length=3." +
                                Environment.NewLine + "	Strings differ at index 1." +
                                Environment.NewLine + "	expected: <\"three\">" +
                                Environment.NewLine + "	 but was: <\"ten\">" +
                                Environment.NewLine + "	-------------^" + Environment.NewLine,
                                msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayArrayDifferences(
                    new object[] { 1, 2, 3 },
                    new object[] { 1, 2, 10 },
                    2);

                Assert.AreEqual("message" +
                                Environment.NewLine + "Array lengths are both 3." +
                                Environment.NewLine + "Arrays differ at index 2." +
                                Environment.NewLine + "	expected: <3>" +
                                Environment.NewLine + "	 but was: <10>" + Environment.NewLine,
                                msg.ToString());

                msg = new AssertionFailureMessage("message");
                msg.DisplayArrayDifferences(
                    new object[, ] {
                    { 1, 2, 3 }, { 4, 5, 6 }
                },
                    new object[, ] {
                    { 1, 2, 9 }, { 4, 5, 6 }
                },
                    2);

                Assert.AreEqual("message" +
                                Environment.NewLine + "Array lengths are both 6." +
                                Environment.NewLine + "Arrays differ at index 2." +
                                Environment.NewLine + "	expected: <3>" +
                                Environment.NewLine + "	 but was: <9>" + Environment.NewLine,
                                msg.ToString());
            }