DisplayStringDifferences() public abstract method

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.
public abstract DisplayStringDifferences ( string expected, string actual, int mismatch, bool ignoreCase, bool clipping ) : void
expected string The expected string value
actual string The actual string value
mismatch int The point at which the strings don't match or -1
ignoreCase bool If true, case is ignored in locating the point where the strings differ
clipping bool If true, the strings should be clipped to fit the line
return void
Esempio n. 1
0
        private void DisplayStringDifferences(MessageWriter writer, string expected, string actual)
        {
            int mismatch = MsgUtils.FindMismatchPosition(expected, actual, 0, caseInsensitive);

            if (expected.Length == actual.Length)
            {
                writer.WriteMessageLine(StringsDiffer_1, expected.Length, mismatch);
            }
            else
            {
                writer.WriteMessageLine(StringsDiffer_2, expected.Length, actual.Length, mismatch);
            }

            writer.DisplayStringDifferences(expected, actual, mismatch, caseInsensitive, clipStrings);
        }
Esempio n. 2
0
        public override void WriteActualValueTo(MessageWriter writer)
        {
            //IF actual is not empty it means we've an issue with Casing or a space at the end
            if (!(actual is IEnumerable<string>))
                return;

            var isApproximate = false;
            foreach (var actualItem in (actual as IEnumerable<string>))
            {
                var text = string.Empty;
                if (actualItem.ToLowerInvariant() == Expected.ToLowerInvariant())
                    text = string.Format("< <{0}> > (case not matching)", actualItem);
                else if (actualItem.TrimEnd() == Expected)
                    text = string.Format("< <{0}> > (with ending space(s))", actualItem);
                else if (actualItem.TrimStart() == Expected)
                    text = string.Format("< <{0}> > (with leading space(s))", actualItem);
                else if (actualItem.ToLowerInvariant().Trim() == Expected.ToLowerInvariant().Trim())
                    text = string.Format("< <{0}> > (small difference)", actualItem);

                if (!string.IsNullOrEmpty(text))
                {
                    writer.WriteActualValue(text);
                    isApproximate = true;
                }
            }

            if (!isApproximate)
            {

                if (((IEnumerable<string>)actual).Count() == 0)
                    writer.WriteActualValue(new WriterHelper.NothingFoundMessage());
                else
                {
                    base.WriteActualValueTo(writer);
                    var closeMatch = GetCloseMatch();
                    if (!string.IsNullOrEmpty(closeMatch))
                    {
                        writer.WriteMessageLine("");
                        writer.WriteMessageLine("");
                        writer.WriteMessageLine(string.Format("The value '{0}' is close to your expectation.", closeMatch));
                        writer.DisplayStringDifferences(Expected, closeMatch, -1, false, true);
                    }
                }
            }
        }
Esempio n. 3
0
 public override void WriteMessageTo(MessageWriter writer)
 {
     WriteFailureMessageTo(writer);
     writer.DisplayStringDifferences((string)expected, (string)actual, -1, caseInsensitive);
 }
Esempio n. 4
0
        private void DisplayStringDifferences(MessageWriter writer, string expected, string actual)
        {
            int mismatch = MsgUtils.FindMismatchPosition(expected, actual, 0, this.caseInsensitive);

            if (expected.Length == actual.Length)
                writer.WriteMessageLine(StringsDiffer_1, expected.Length, mismatch);
            else
                writer.WriteMessageLine(StringsDiffer_2, expected.Length, actual.Length, mismatch);

            writer.DisplayStringDifferences(expected, actual, mismatch, caseInsensitive);
        }
Esempio n. 5
0
        public override void WriteActualValueTo(MessageWriter writer)
        {
            //IF actual is not empty it means we've an issue with Casing or a space at the end
            if (actual is IEnumerable<IField> && ((IEnumerable<IField>)actual).Count() == 1)
            {
                if (((IEnumerable<IField>)actual).ToArray()[0].Caption.ToLowerInvariant() == Expected.ToLowerInvariant())
                    writer.WriteActualValue(string.Format("< <{0}> > (case not matching)", ((IEnumerable<IField>)actual).ToArray()[0].Caption));
                else if (((IEnumerable<IField>)actual).ToArray()[0].Caption.EndsWith(" "))
                    writer.WriteActualValue(string.Format("< <{0}> > (with ending space(s))", ((IEnumerable<IField>)actual).ToArray()[0].Caption));
                else
                    writer.WriteActualValue(string.Format("< <{0}> > (small difference)", ((IEnumerable<IField>)actual).ToArray()[0].Caption));

            }
            else
            {
                Investigate();

                if (actual is IEnumerable<IField> && ((IEnumerable<IField>)actual).Count() > 0)
                    base.WriteActualValueTo(writer);
                else
                    writer.WriteActualValue(new WriterHelper.NothingFoundMessage());

                var closeMatch = GetCloseMatch();
                if (!string.IsNullOrEmpty(closeMatch))
                {
                    writer.WriteMessageLine("");
                    writer.WriteMessageLine("");
                    writer.WriteMessageLine(string.Format("The value '{0}' is close to your expectation.", closeMatch));
                    writer.DisplayStringDifferences(Expected, closeMatch, -1, false, true);
                }
            }
        }
		public override void WriteMessageTo(MessageWriter writer)
		{
			if (_expectedLine == null)
			{
				writer.WriteMessageLine("Expected end of string (null), actual was '{0}'", _actualLine);
				return;
			}
			if (_actualLine == null)
			{
				writer.WriteMessageLine("Expected string '{0}', actual was at end (null)", _expectedLine);
				return;
			}
			writer.DisplayStringDifferences(_expectedLine, _actualLine, 0, false, true);
		}
 public override void WriteMessageTo(MessageWriter writer)
 {
     writer.WriteMessageLine("Difference at {0}", Path);
     writer.DisplayStringDifferences(Expected, Actual, Expected.Zip(Actual, (c1, c2) => c1 == c2).ToList().IndexOf(false), false, true);
 }
 public override void WriteMessageTo(MessageWriter writer)
 {
     WriteFailureMessageTo(writer);
     writer.DisplayStringDifferences((string)expected, (string)actual, -1, caseInsensitive);
 }