本文整理汇总了C#中NUnit.Framework.Constraints.MessageWriter.DisplayStringDifferences方法的典型用法代码示例。如果您正苦于以下问题:C# MessageWriter.DisplayStringDifferences方法的具体用法?C# MessageWriter.DisplayStringDifferences怎么用?C# MessageWriter.DisplayStringDifferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.Constraints.MessageWriter
的用法示例。
在下文中一共展示了MessageWriter.DisplayStringDifferences方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteActualValueTo
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);
}
}
}
}
示例2: DisplayStringDifferences
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);
}
示例3: WriteActualValueTo
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);
}
}
}
示例4: WriteMessageTo
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);
}
示例5: WriteMessageTo
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);
}
示例6: WriteMessageTo
public override void WriteMessageTo(MessageWriter writer)
{
WriteFailureMessageTo(writer);
writer.DisplayStringDifferences((string)expected, (string)actual, -1, caseInsensitive);
}