public void TryMatchPassTest() { var diag = new MatchDiagnostics(); var matcher = new MyMatcher("MyValue"); var matched = diag.TryMatch("MyValue", "MyProperty", matcher); Assert.IsTrue(matched, "Expected matcher to match"); var expect = new StringBuilder(); expect.AppendLine("Match"); expect.AppendLine(Indent + "named:MyProperty"); expect.AppendLine(Indent + "Equals:MyValue"); AssertEquals(expect.ToString(), diag.ToString()); }
public void TryMatchFailTest() { var diag = new MatchDiagnostics(); var matcher = new MyMatcher("MyValue"); var matched = diag.TryMatch("MyWrongValue", "MyProperty", matcher); Assert.IsFalse(matched, "Expected matcher to _not_ match"); var expect = new StringBuilder(); expect.AppendLine("Mismatch!"); expect.AppendLine(Indent + "named:MyProperty"); expect.AppendLine(Indent + "matcherType:" + matcher.GetType()); expect.AppendLine(Indent + "expected:"); expect.AppendLine(Indent + Indent + "Equals:MyValue"); expect.AppendLine(Indent + "but was (string,length 12,quoted):"); expect.AppendLine(Indent + Indent + "'MyWrongValue'"); expect.AppendLine(Indent + "Mismatch!"); expect.AppendLine(Indent + Indent + "expected:MyValue"); expect.AppendLine(Indent + Indent + "actual:MyWrongValue"); AssertEquals(expect.ToString(), diag.ToString()); }