Example #1
0
        private string GetErrorMessage(DifferenceMode summary)
        {
            var mainText = GetMessage(summary);

            const int extractLength = 20;
            string    actual;
            string    expected;

            if (this.Line > 0 || this.Expected.Length > extractLength * 2 || this.Actual.Length > extractLength * 2)
            {
                actual   = this.HighLightForDifference(this.Actual.Extract(this.Position, extractLength));
                expected = this.HighLightForDifference(this.Expected.Extract(this.Position, extractLength));
            }
            else
            {
                actual   = this.HighLightForDifference(this.Actual);
                expected = this.HighLightForDifference(this.Expected);
            }

            if (!this.IsFullText || (this.Actual != actual || this.Expected != expected))
            {
                mainText += string.Format(
                    " At line {0}, col {3}, expected '{1}' was '{2}'.",
                    this.Line + 1,
                    expected,
                    actual,
                    this.Position + 1);
            }

            return(mainText);
        }
Example #2
0
 private DifferenceDetails(string firstName, object firstValue, object secondValue, int index, DifferenceMode mode)
 {
     this.mode        = mode;
     this.FirstName   = firstName;
     this.FirstValue  = firstValue;
     this.SecondValue = secondValue;
     this.Index       = index;
 }
Example #3
0
 private StringDifference(DifferenceMode mode, int line, int position, string actual, string expected, bool isFulltext)
 {
     this.Kind       = mode;
     this.Line       = line;
     this.Position   = position;
     this.Expected   = expected;
     this.Actual     = actual;
     this.IsFullText = isFulltext;
 }
Example #4
0
        /// <summary>
        /// Get general message
        /// </summary>
        /// <param name="summary">Synthetic error</param>
        /// <returns></returns>
        public static string GetMessage(DifferenceMode summary)
        {
            string message;

            switch (summary)
            {
            default:
                message = "The {0} is different from {1}.";
                break;

            case DifferenceMode.GeneralSameLength:
                message = "The {0} is different from the {1} but has same length.";
                break;

            case DifferenceMode.Spaces:
                message = "The {0} has different spaces than {1}.";
                break;

            case DifferenceMode.EndOfLine:
                message = "The {0} has different end of line markers than {1}.";
                break;

            case DifferenceMode.CaseDifference:
                message = "The {0} is different in case from the {1}.";
                break;

            case DifferenceMode.ExtraLines:
                message = "The {0} is different from {1}, it contains extra lines at the end.";
                break;

            case DifferenceMode.LongerLine:
                message = "The {0} is different from {1}, one line is longer.";
                break;

            case DifferenceMode.ShorterLine:
                message = "The {0} is different from {1}, one line is shorter.";
                break;

            case DifferenceMode.MissingLines:
                message = "The {0} is different from {1}, it is missing some line(s).";
                break;

            case DifferenceMode.Longer:
                message = "The {0} is different from {1}, it contains extra text at the end.";
                break;

            case DifferenceMode.Shorter:
                message = "The {0} is different from {1}, it is missing the end.";
                break;
            }

            return(message);
        }
Example #5
0
        private string GetErrorMessage(DifferenceMode summary)
        {
            var mainText = GetMessage(summary);

            const int extractLength = 20;
            string    actual;
            string    expected;

            if (this.Line > 0 || this.Expected.Length > extractLength * 2 || this.Actual.Length > extractLength * 2)
            {
                actual   = this.Actual.Extract(this.Position, extractLength);
                expected = this.Expected.Extract(this.Position, extractLength);
            }
            else
            {
                actual   = this.Actual;
                expected = this.Expected;
            }
            actual   = this.HighLightForDifference(actual);
            expected = this.HighLightForDifference(expected);

            if (!this.IsFullText || this.Actual != actual || this.Expected != expected)
            {
                if (summary == DifferenceMode.MissingLines)
                {
                    mainText +=
                        $" At line {this.Line + 1}, expected '{HighlightCrlfOrLfIfAny(expected)}' but line is missing.";
                }
                else if (summary == DifferenceMode.ExtraLines)
                {
                    mainText +=
                        $" Found line {this.Line + 1} '{HighlightCrlfOrLfIfAny(actual)}'.";
                }
                else
                {
                    mainText += string.Format(
                        " At line {0}, col {3}, expected '{1}' was '{2}'.",
                        this.Line + 1,
                        HighlightCrlfOrLfIfAny(expected),
                        HighlightCrlfOrLfIfAny(actual),
                        this.Position + 1);
                }
            }

            return(mainText);
        }