WriteMessageLine() public abstract method

Method to write single line message with optional args, usually written to precede the general failure message, at a given indentation level.
public abstract WriteMessageLine ( int level, string message ) : void
level int The indentation level of the message
message string The message to be written
return void
示例#1
0
        /// <summary>
        /// Displays a single line showing the types and sizes of the expected
        /// and actual collections or arrays. If both are identical, the value is
        /// only shown once.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection or array</param>
        /// <param name="actual">The actual collection or array</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayTypesAndSizes(MessageWriter writer, IEnumerable expected, IEnumerable actual, int indent)
        {
            string sExpected = MsgUtils.GetTypeRepresentation(expected);

            if (expected is ICollection && !(expected is Array))
            {
                sExpected += string.Format(" with {0} elements", ((ICollection)expected).Count);
            }

            string sActual = MsgUtils.GetTypeRepresentation(actual);

            if (actual is ICollection && !(actual is Array))
            {
                sActual += string.Format(" with {0} elements", ((ICollection)actual).Count);
            }

            if (sExpected == sActual)
            {
                writer.WriteMessageLine(indent, CollectionType_1, sExpected);
            }
            else
            {
                writer.WriteMessageLine(indent, CollectionType_2, sExpected, sActual);
            }
        }
示例#2
0
        /// <summary>
        /// Displays a single line showing the point in the expected and actual
        /// arrays at which the comparison failed. If the arrays have different
        /// structures or dimensions, both values are shown.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected array</param>
        /// <param name="actual">The actual array</param>
        /// <param name="failurePoint">Index of the failure point in the underlying collections</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayFailurePoint(MessageWriter writer, IEnumerable expected, IEnumerable actual, NUnitEqualityComparer.FailurePoint failurePoint, int indent)
        {
            Array expectedArray = expected as Array;
            Array actualArray   = actual as Array;

            int expectedRank = expectedArray != null ? expectedArray.Rank : 1;
            int actualRank   = actualArray != null ? actualArray.Rank : 1;

            bool useOneIndex = expectedRank == actualRank;

            if (expectedArray != null && actualArray != null)
            {
                for (int r = 1; r < expectedRank && useOneIndex; r++)
                {
                    if (expectedArray.GetLength(r) != actualArray.GetLength(r))
                    {
                        useOneIndex = false;
                    }
                }
            }

            int[] expectedIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(expected, failurePoint.Position);
            if (useOneIndex)
            {
                writer.WriteMessageLine(indent, ValuesDiffer_1, MsgUtils.GetArrayIndicesAsString(expectedIndices));
            }
            else
            {
                int[] actualIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(actual, failurePoint.Position);
                writer.WriteMessageLine(indent, ValuesDiffer_2,
                                        MsgUtils.GetArrayIndicesAsString(expectedIndices), MsgUtils.GetArrayIndicesAsString(actualIndices));
            }
        }
 protected override void WriteFailureMessageTo(MessageWriter writer)
 {
     if (caseInsensitive)
         writer.WriteMessageLine(msg_DoesNotContain_IC);
     else
         writer.WriteMessageLine(msg_DoesNotContain);
 }
示例#4
0
        private void DisplayFailurePoint(MessageWriter writer, IEnumerable expected, IEnumerable actual, NUnitEqualityComparer.FailurePoint failurePoint, int indent)
        {
            Array array  = expected as Array;
            Array array2 = actual as Array;
            int   num    = array?.Rank ?? 1;
            int   num2   = array2?.Rank ?? 1;
            bool  flag   = num == num2;

            if (array != null && array2 != null)
            {
                for (int i = 1; i < num; i++)
                {
                    if (!flag)
                    {
                        break;
                    }
                    if (array.GetLength(i) != array2.GetLength(i))
                    {
                        flag = false;
                    }
                }
            }
            int[] arrayIndicesFromCollectionIndex = MsgUtils.GetArrayIndicesFromCollectionIndex(expected, failurePoint.Position);
            if (flag)
            {
                writer.WriteMessageLine(indent, ValuesDiffer_1, MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex));
                return;
            }
            int[] arrayIndicesFromCollectionIndex2 = MsgUtils.GetArrayIndicesFromCollectionIndex(actual, failurePoint.Position);
            writer.WriteMessageLine(indent, ValuesDiffer_2, MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex), MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex2));
        }
示例#5
0
 public override void WriteActualValueTo(MessageWriter writer)
 {
     writer.WriteMessageLine("Left part failed reason:\n\t");
     leftConstraint.WriteActualValueTo(writer);
     writer.WriteMessageLine("Right part failed reason:\n\t");
     rightConstraint.WriteActualValueTo(writer);
 }
示例#6
0
		public override void WriteMessageTo(MessageWriter writer) {
			if (this.actual is IProperty) {
				writer.WriteMessageLine("Expected {0} to have an empty {1} accessor but it was not empty {2}.", this.actual, this.accessorText, this.RegionToTest);
			} else {
				writer.WriteMessageLine("{0} is not an IProperty; cannot test for the emptiness of a {1} accessor.", this.actual, this.accessorText);
			}
		}
示例#7
0
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WriteMessageLine("Expected to find element with css selector: {0}\nin:\n{1}", _expectedCss, _actualContent);
     if (exactText != null)
         writer.WriteMessageLine("With text: \"" + exactText + "\"");
     if (textPattern != null)
         writer.WriteMessageLine("With text matching: \"" + textPattern + "\"");
 }
示例#8
0
 public override void WriteMessageTo(MessageWriter writer)
 {
     if (this.actual is IMethod) {
         writer.WriteMessageLine("Expected {0} to have an empty BodyRegion but it was not empty {1}.", this.m, this.m.BodyRegion);
     } else {
         writer.WriteMessageLine("{0} is not an IMethod; cannot test for the emptiness of a it's BodyRegion.", this.actual);
     }
 }
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WriteMessageLine("Expected to find elements from css selector: {0}\r\nContaining only:\r\n", _expectedCss);
     if (exactText != null)
         writer.WriteMessageLine(string.Format("[{0}]", string.Join(",", exactText)));
     if (textPattern != null)
         writer.WriteMessageLine(string.Format("[{0}]", string.Join(",", textPattern.Select(p => p.ToString()).ToArray())));
     
 }
示例#10
0
 /// <summary/>
 public override void WriteMessageTo(MessageWriter writer)
 {
     writer.WriteMessageLine(GetType().FullName + " Failed!");
     using (StringReader reader = new StringReader(message.ToString()))
     {
         string line;
         while ((line = reader.ReadLine()) != null)
             writer.WriteMessageLine(line);
     }
 }
 public override void WriteMessageTo(MessageWriter writer)
 {
     if (this.actual is IProperty)
     {
         writer.WriteMessageLine("Expected {0} to have an empty {1} accessor but it was not empty {2}.", this.actual, this.accessorText, this.RegionToTest);
     }
     else
     {
         writer.WriteMessageLine("{0} is not an IProperty; cannot test for the emptiness of a {1} accessor.", this.actual, this.accessorText);
     }
 }
示例#12
0
 protected override void WriteFailureMessageTo(MessageWriter writer)
 {
     if (caseInsensitive)
     {
         writer.WriteMessageLine(msg_DoesNotContain_IC);
     }
     else
     {
         writer.WriteMessageLine(msg_DoesNotContain);
     }
 }
 public override void WriteMessageTo(MessageWriter writer)
 {
     if (this.actual is IMethod)
     {
         writer.WriteMessageLine("Expected {0} to have an empty BodyRegion but it was not empty {1}.", this.m, this.m.BodyRegion);
     }
     else
     {
         writer.WriteMessageLine("{0} is not an IMethod; cannot test for the emptiness of a it's BodyRegion.", this.actual);
     }
 }
示例#14
0
 public override void WriteActualValueTo(MessageWriter writer)
 {
     if (!leftOk) {
         writer.WriteMessageLine("Left part of the And is false because ");
         leftConstraint.WriteActualValueTo(writer);
     } else if (!rightOk) {
         writer.WriteMessageLine("Right part of the And is false because ", leftOk);
         rightConstraint.WriteActualValueTo(writer);
     } else {
         Debug.Fail("This code should be not reached");
     }
 }
示例#15
0
 private void DisplayStreamDifferences(MessageWriter writer, Stream expected, Stream actual, int depth)
 {
     if (expected.Length == actual.Length)
     {
         long num = (long)comparer.FailurePoints[depth];
         writer.WriteMessageLine(StreamsDiffer_1, expected.Length, num);
     }
     else
     {
         writer.WriteMessageLine(StreamsDiffer_2, expected.Length, actual.Length);
     }
 }
示例#16
0
 private void DisplayStreamDifferences(MessageWriter writer, Stream expected, Stream actual, int depth)
 {
     if (expected.Length == actual.Length)
     {
         long offset = failurePoints[depth].Position;
         writer.WriteMessageLine(StreamsDiffer_1, expected.Length, offset);
     }
     else
     {
         writer.WriteMessageLine(StreamsDiffer_2, expected.Length, actual.Length);
     }
 }
		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);
		}
示例#18
0
        /// <summary>
        /// Displays a single line showing the types and sizes of the expected
        /// and actual collections or arrays. If both are identical, the value is
        /// only shown once.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection or array</param>
        /// <param name="actual">The actual collection or array</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayCollectionTypesAndSizes(MessageWriter writer, ICollection expected, ICollection actual, int indent)
        {
            string expectedType = MsgUtils.GetTypeRepresentation(expected);
            string actualType   = MsgUtils.GetTypeRepresentation(actual);

            if (expectedType == actualType)
            {
                writer.WriteMessageLine(indent, CollectionType_1, expectedType);
            }
            else
            {
                writer.WriteMessageLine(indent, CollectionType_2, expectedType, actualType);
            }
        }
示例#19
0
        private void DisplayStringDifferences(MessageWriter writer, string expected, string actual)
        {
            int num = MsgUtils.FindMismatchPosition(expected, actual, 0, comparer.IgnoreCase);

            if (expected.Length == actual.Length)
            {
                writer.WriteMessageLine(StringsDiffer_1, expected.Length, num);
            }
            else
            {
                writer.WriteMessageLine(StringsDiffer_2, expected.Length, actual.Length, num);
            }
            writer.DisplayStringDifferences(expected, actual, num, comparer.IgnoreCase, clipStrings);
        }
示例#20
0
 public override void WriteActualValueTo(NUnitCtr.MessageWriter writer)
 {
     if (invalidMembers.Count == 1)
     {
         writer.WriteMessageLine(string.Format("The element <{0}> doesn't validate this pattern", invalidMembers[0]));
     }
     else
     {
         writer.WriteMessageLine(string.Format("{0} elements don't validate this pattern:", invalidMembers.Count));
         foreach (var invalidMember in invalidMembers)
         {
             writer.WriteMessageLine(string.Format("    <{0}>", invalidMember));
         }
     }
 }
示例#21
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);
        }
 public override void WriteActualValueTo(MessageWriter writer)
 {
     writer.WriteActualValue(" found count (" + MatchCount.ToString() + ")");
     writer.Write("[");
     baseConstraint.WriteDescriptionTo(writer);
     writer.WriteMessageLine("] expected count of {0}", countOccurrence );
 }
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     this.actual = "Found " + differencies.Count + " differencies between two objects";
     differencies.ForEach(s =>
     {
         writer.WriteMessageLine(s);
     });
 }
示例#24
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);
                    }
                }
            }
        }
            public override void WriteAdditionalLinesTo(MessageWriter writer)
            {
                if (_extraItems?.Count > 0)
                {
                    string extraItemsMessage = "Extra items: ";
                    extraItemsMessage += MsgUtils.FormatCollection(_extraItems);

                    writer.WriteMessageLine(extraItemsMessage);
                }
            }
            public override void WriteAdditionalLinesTo(MessageWriter writer)
            {
                if (_missingItems?.Count > 0)
                {
                    string missingItemsMessage = "Missing items: ";
                    missingItemsMessage += MsgUtils.FormatCollection(_missingItems);

                    writer.WriteMessageLine(missingItemsMessage);
                }
            }
示例#27
0
        /// <summary>
        /// Displays a single line showing the types and sizes of the expected
        /// and actual collections or arrays. If both are identical, the value is
        /// only shown once.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection or array</param>
        /// <param name="actual">The actual collection or array</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayCollectionTypesAndSizes(MessageWriter writer, ICollection expected, ICollection actual, int indent)
        {
            string sExpected = MsgUtils.GetTypeRepresentation(expected);
            //if (!(expected is Array))
            //    sExpected += string.Format(" with {0} elements", expected.Count);

            string sActual = MsgUtils.GetTypeRepresentation(actual);

            //if (!(actual is Array))
            //    sActual += string.Format(" with {0} elements", actual.Count);

            if (sExpected == sActual)
            {
                writer.WriteMessageLine(indent, CollectionType_1, sExpected);
            }
            else
            {
                writer.WriteMessageLine(indent, CollectionType_2, sExpected, sActual);
            }
        }
示例#28
0
        private void DisplayTypesAndSizes(MessageWriter writer, IEnumerable expected, IEnumerable actual, int indent)
        {
            string text = MsgUtils.GetTypeRepresentation(expected);

            if (expected is ICollection && !(expected is Array))
            {
                text += $" with {((ICollection)expected).Count} elements";
            }
            string text2 = MsgUtils.GetTypeRepresentation(actual);

            if (actual is ICollection && !(actual is Array))
            {
                text2 += $" with {((ICollection)actual).Count} elements";
            }
            if (text == text2)
            {
                writer.WriteMessageLine(indent, CollectionType_1, text);
            }
            else
            {
                writer.WriteMessageLine(indent, CollectionType_2, text, text2);
            }
        }
 /// <summary>
 /// Writes the member that did not match.
 /// </summary>
 public void WriteOffendingMember(MessageWriter writer)
 {
     writer.WriteMessageLine(0, Member);
 }
示例#30
0
文件: Shows.cs 项目: prolee/coypu
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WriteMessageLine("{0} content: {1}\nin:\n{2}", FailureMessagePrefix, _expectedContent, _actualContent);
 }
示例#31
0
        /// <summary>
        /// Displays a single line showing the types and sizes of the expected
        /// and actual collections or arrays. If both are identical, the value is 
        /// only shown once.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection or array</param>
        /// <param name="actual">The actual collection or array</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayCollectionTypesAndSizes(MessageWriter writer, ICollection expected, ICollection actual, int indent)
        {
            string sExpected = MsgUtils.GetTypeRepresentation(expected);
            if (!(expected is Array))
                sExpected += string.Format(" with {0} elements", expected.Count);

            string sActual = MsgUtils.GetTypeRepresentation(actual);
            if (!(actual is Array))
                sActual += string.Format(" with {0} elements", expected.Count);

            if (sExpected == sActual)
                writer.WriteMessageLine(indent, CollectionType_1, sExpected);
            else
                writer.WriteMessageLine(indent, CollectionType_2, sExpected, sActual);
        }
示例#32
0
文件: Meta.cs 项目: SealedSun/prx
     override void WriteDescriptionTo(MessageWriter writer)
 {
     writer.WriteMessageLine(
         "meta table of object {0} should contain an entry for key \"{1}\"", actual, _key);
 }
示例#33
0
文件: Meta.cs 项目: SealedSun/prx
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     if (actual == null)
     {
         writer.WriteMessageLine("Actual value does not have a meta table.");
     }
     else if (_typeMismatch)
     {
         writer.WriteMessageLine("Meta entry type doesn't match.");
         writer.WriteExpectedValue(_expectedEntry.EntryType);
         writer.WriteActualValue(_actualEntry.EntryType);
     }
     else
     {
         writer.WriteMessageLine(
             "actual meta entry {0} should match expected entry {1}", _actualEntry,
             _expectedEntry);
     }
 }
示例#34
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);
        }
 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)
 {
     writer.WriteMessageLine("Difference at {0}", Path);
     writer.DisplayDifferences(Expected, Actual);
 }
示例#37
0
 public override void WriteDescriptionTo(MessageWriter writer) {
     writer.WriteMessageLine("Expected NOT to find content: {0}\nin:\n{1}", _expectedContent, _actualContent);
 }
 public override void WriteDescriptionTo(MessageWriter writer)
 {
     if (writer != null) {
         writer.WriteMessageLine("Equal By Property Constraint");
     }
 }
 public override void WriteActualValueTo(MessageWriter writer)
 {
     writer.WriteMessageLine(string.Format("\r\n{0}", _actualContent));
 }
示例#40
0
 private void DisplayStreamDifferences(MessageWriter writer, Stream expected, Stream actual, int depth)
 {
     if (expected.Length == actual.Length)
     {
         long offset = (long)failurePoints[depth];
         writer.WriteMessageLine(StreamsDiffer_1, expected.Length, offset);
     }
     else
         writer.WriteMessageLine(StreamsDiffer_2, expected.Length, actual.Length);
 }
        public override void WriteDescriptionTo(MessageWriter writer)
        {
            writer.WriteExpectedValue(_expectedValue);

            if (_context != null)
                writer.WriteMessageLine("In " + _context);
        }
示例#42
0
        /// <summary>
        /// Displays a single line showing the types and sizes of the expected
        /// and actual collections or arrays. If both are identical, the value is 
        /// only shown once.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection or array</param>
        /// <param name="actual">The actual collection or array</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayCollectionTypesAndSizes(MessageWriter writer, ICollection expected, ICollection actual, int indent)
        {
            string expectedType = MsgUtils.GetTypeRepresentation(expected);
            string actualType = MsgUtils.GetTypeRepresentation(actual);

            if (expectedType == actualType)
                writer.WriteMessageLine(indent, CollectionType_1, expectedType);
            else
                writer.WriteMessageLine(indent, CollectionType_2, expectedType, actualType);
        }
示例#43
0
 protected override void WriteFailureMessageTo(MessageWriter writer)
 {
     writer.WriteMessageLine("String does not match the pattern provided");
 }
示例#44
0
        /// <summary>
        /// Displays a single line showing the point in the expected and actual
        /// arrays at which the comparison failed. If the arrays have different
        /// structures or dimensions, both values are shown.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected array</param>
        /// <param name="actual">The actual array</param>
        /// <param name="failurePoint">Index of the failure point in the underlying collections</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayFailurePoint(MessageWriter writer, ICollection expected, ICollection actual, int failurePoint, int indent)
        {
            Array expectedArray = expected as Array;
            Array actualArray = actual as Array;

            int expectedRank = expectedArray != null ? expectedArray.Rank : 1;
            int actualRank = actualArray != null ? actualArray.Rank : 1;

            bool useOneIndex = expectedRank == actualRank;

            if (expectedArray != null && actualArray != null)
                for (int r = 1; r < expectedRank && useOneIndex; r++)
                    if (expectedArray.GetLength(r) != actualArray.GetLength(r))
                        useOneIndex = false;

            int[] expectedIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(expected, failurePoint);
            if (useOneIndex)
            {
                writer.WriteMessageLine(indent, ValuesDiffer_1, MsgUtils.GetArrayIndicesAsString(expectedIndices));
            }
            else
            {
                int[] actualIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(actual, failurePoint);
                writer.WriteMessageLine(indent, ValuesDiffer_2,
                    MsgUtils.GetArrayIndicesAsString(expectedIndices), MsgUtils.GetArrayIndicesAsString(actualIndices));
            }
        }
示例#45
0
 protected override void WriteFailureMessageTo(MessageWriter writer)
 {
     writer.WriteMessageLine( "String does not match the pattern provided" );
 }
示例#46
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);
                }
            }
        }