/// <summary> /// Display the expected and actual string values on separate lines. /// If the mismatch parameter is >=0, an additional line is displayed /// line containing a caret that points to the mismatch point. /// </summary> /// <param name="expected">The expected string value</param> /// <param name="actual">The actual string value</param> /// <param name="mismatch">The point at which the strings don't match or -1</param> /// <param name="ignoreCase">If true, case is ignored in string comparisons</param> /// <param name="clipping">If true, clip the strings to fit the max line length</param> public override void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase, bool clipping) { // Maximum string we can display without truncating int maxDisplayLength = MaxLineLength - PrefixLength // Allow for prefix - 2; // 2 quotation marks if (clipping) { MsgUtils.ClipExpectedAndActual(ref expected, ref actual, maxDisplayLength, mismatch); } expected = MsgUtils.EscapeControlChars(expected); actual = MsgUtils.EscapeControlChars(actual); // The mismatch position may have changed due to clipping or white space conversion mismatch = MsgUtils.FindMismatchPosition(expected, actual, 0, ignoreCase); Write(Pfx_Expected); WriteExpectedValue(expected); if (ignoreCase) { WriteModifier("ignoring case"); } WriteLine(); WriteActualLine(actual); //DisplayDifferences(expected, actual); if (mismatch >= 0) { WriteCaretLine(mismatch); } }
/// <summary> /// Display the expected and actual string values on separate lines. /// If the mismatch parameter is >=0, an additional line is displayed /// line containing a caret that points to the mismatch point. /// </summary> /// <param name="expected">The expected string value</param> /// <param name="actual">The actual string value</param> /// <param name="mismatch">The point at which the strings don't match or -1</param> /// <param name="ignoreCase">If true, case is ignored in string comparisons</param> public override void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase) { // Maximum string we can display without truncating int maxStringLength = MAX_LINE_LENGTH - PrefixLength // Allow for prefix - 2; // 2 quotation marks expected = MsgUtils.ConvertWhitespace(MsgUtils.ClipString(expected, maxStringLength, mismatch)); actual = MsgUtils.ConvertWhitespace(MsgUtils.ClipString(actual, maxStringLength, mismatch)); // The mismatch position may have changed due to clipping or white space conversion mismatch = MsgUtils.FindMismatchPosition(expected, actual, 0, ignoreCase); DisplayDifferences(expected, actual); if (mismatch >= 0) { WriteCaretLine(mismatch); } }