public void TestTwoExtraValues()
        {
            List <object> actualList = new List <object>()
            {
                "one", "two", "three", "four"
            };
            ConstraintResult cr = _constraint.ApplyTo(actualList);

            cr.WriteMessageTo(_writer);

            string expectedMsg =
                "  Expected: equivalent to < \"one\", \"two\" >" + Environment.NewLine +
                "  But was:  < \"one\", \"two\", \"three\", \"four\" >" + Environment.NewLine +
                "  Extra (2): < \"three\", \"four\" >" + Environment.NewLine;

            Assert.AreEqual(expectedMsg, _writer.ToString());
        }
        public void TestOneMissingValue()
        {
            List <object> actualList = new List <object>()
            {
                "one"
            };

            ConstraintResult cr = _constraint.ApplyTo(actualList);

            cr.WriteMessageTo(_writer);

            string expectedMsg =
                "  Expected: equivalent to < \"one\", \"two\" >" + Environment.NewLine +
                "  But was:  < \"one\" >" + Environment.NewLine +
                "  Missing (1): < \"two\" >" + Environment.NewLine;

            Assert.AreEqual(expectedMsg, _writer.ToString());
        }
        public void TestOnlyDisplaysUpToTenDifferences()
        {
            List <object> actualList = new List <object>()
            {
                "one", "two", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven"
            };

            ConstraintResult cr = _constraint.ApplyTo(actualList);

            cr.WriteMessageTo(_writer);

            string expectedMsg =
                "  Expected: equivalent to < \"one\", \"two\" >" + Environment.NewLine +
                "  But was:  < \"one\", \"two\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\"... >" + Environment.NewLine +
                "  Extra (11): < \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\"... >" + Environment.NewLine;

            Assert.AreEqual(expectedMsg, _writer.ToString());
        }
Example #4
0
        private static void ReportFailure(ConstraintResult result, string message, params object[] args)
        {
            MessageWriter writer = new TextMessageWriter(message, args);
            result.WriteMessageTo(writer);

            ReportFailure(writer.ToString());
        }