public static void AssertText(string expected, string actual, IApprovalFailureReporter reporter = null) { if (reporter == null) { reporter = GetReporter(DiffReporter.INSTANCE); } reporter = new MultiReporter(reporter, InlineTextReporter.INSTANCE); StringReporting.AssertEqual(expected, actual, reporter); }
public void CustomizeErrorReporting() { var reporter = new StringReporting(); var oldReporter = Check.Reporter; Check.Reporter = reporter; try { Check.That(12).IsNotEqualTo(12); } finally { Check.Reporter = oldReporter; } Check.That(reporter.Error).AsLines().ContainsExactly("", "The checked value is equal to the given one whereas it must not.", "The expected value: different from", "\t[12] of type: [int]"); }
public static void CompareArrays <T>(T[] n1, string label1, T[] n2, string label2) { Array.Sort(n1); Array.Sort(n2); bool failed = n1.Length != n2.Length; for (var i = 0; i < n1.Length && !failed; i++) { if (!n1[i].Equals(n2[i])) { failed = true; } } if (failed) { var method2 = ToText(n2, label2); var method1 = ToText(n1, label1); StringReporting.DiffWith(method2, method1); throw new Exception("Race condition detected"); } }
public static void AssertEquals(string expected, string actual) { StringReporting.AssertEqual(expected, actual, GetReporter()); }
public static void AssertEquals <T>(string expected, string actual) where T : IApprovalFailureReporter, new() { StringReporting.AssertEqual(expected, actual, new T()); }
public static void AssertEquals(string expected, string actual, IApprovalFailureReporter reporter) { StringReporting.AssertEqual(expected, actual, reporter); }