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 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()); }
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()); }