public void Append_string()
        {
            var          description = new StringDescription(new StringBuilder());
            const string value       = "test";

            description.AppendText(value);

            Assert.AreEqual(value, description.ToString());
        }
        private static string BuildFailureMessage <T>(string summary, T actual, Matcher <T> matcher)
        {
            Description description = new StringDescription();

            if (matcher != null)
            {
                description.AppendText("instead ");
                matcher.DescribeTo(description);
                matcher.DescribeMismatch(actual, description);
            }
            else
            {
                description.AppendText("instead [not displayed] was visible");
            }
            string descriptionString = description.ToString().Replace("<", "[").Replace(">", "]");

            return(summary + ": " + descriptionString);
        }
        public void Append_string()
        {
            var description = new StringDescription(new StringBuilder());
            const string value = "test";

            description.AppendText(value);

            Assert.AreEqual(value, description.ToString());
        }
        public static string MatcherSummary <T>(Matcher <T> matcher)
        {
            Description description = new StringDescription();

            if (matcher != null)
            {
                matcher.DescribeTo(description);
            }
            else
            {
                description.AppendText("not displayed");
            }
            return(description.ToString());
        }
Beispiel #5
0
        private static void That <T>(T actual, IMatcher <T> matcher, string reason)
        {
            if (matcher.Matches(actual))
            {
                return;
            }

            var description = new StringDescription();

            description.AppendText(reason)
            .AppendText("\nExpected: ")
            .AppendDescriptionOf(matcher)
            .AppendText("\n     but: ");
            matcher.DescribeMismatch(actual, description);

            throw new AssertionError(description.ToString());
        }