本文整理汇总了C#中NUnit.Framework.Constraints.MessageWriter类的典型用法代码示例。如果您正苦于以下问题:C# MessageWriter类的具体用法?C# MessageWriter怎么用?C# MessageWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageWriter类属于NUnit.Framework.Constraints命名空间,在下文中一共展示了MessageWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteActualValueTo
public override void WriteActualValueTo(MessageWriter writer)
{
writer.WriteActualValue(" found count (" + MatchCount.ToString() + ")");
writer.Write("[");
baseConstraint.WriteDescriptionTo(writer);
writer.WriteMessageLine("] expected count of {0}", countOccurrence );
}
示例2: WriteDescriptionTo
/// <summary>
/// Write a description of the constraint to a MessageWriter
/// </summary>
/// <param name="writer"></param>
public override void WriteDescriptionTo(MessageWriter writer)
{
var description = new DescriptionStructureHelper();
var filterExpression = description.GetFilterExpression(Request.GetAllFilters());
if (Expected.Count() == 1)
{
writer.WritePredicate(string.Format("find a {0} named '{1}' contained {2}",
description.GetTargetExpression(Request.Target),
Expected.First(),
filterExpression));
}
else
{
var expectationExpression = new StringBuilder();
foreach (string item in Expected)
expectationExpression.AppendFormat("<{0}>, ", item);
expectationExpression.Remove(expectationExpression.Length - 2, 2);
writer.WritePredicate(string.Format("find the {0} named '{1}' contained {2}",
description.GetTargetPluralExpression(Request.Target),
expectationExpression.ToString(),
filterExpression));
}
}
示例3: WriteFailureMessageTo
protected override void WriteFailureMessageTo(MessageWriter writer)
{
if (caseInsensitive)
writer.WriteMessageLine(msg_DoesNotContain_IC);
else
writer.WriteMessageLine(msg_DoesNotContain);
}
示例4: WriteDescriptionTo
public override void WriteDescriptionTo(MessageWriter writer)
{
//WritePredicateTo(writer);
writer.WriteExpectedValue(expected);
//if (ignoreCase)
// writer.Write(" ignoring case");
}
示例5: WriteActualValueTo
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: WriteMessageTo
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: WriteActualValueTo
/// <summary>
/// Write the actual value for a failing constraint test to a
/// MessageWriter. The default implementation simply writes
/// the raw value of actual, leaving it to the writer to
/// perform any formatting.
/// </summary>
/// <param name="writer">The writer on which the actual value is displayed</param>
public override void WriteActualValueTo(MessageWriter writer)
{
if ( propertyExists )
writer.WriteActualValue( propValue );
else
writer.WriteActualValue( actual.GetType() );
}
示例8: WriteDescriptionTo
/// <summary>
/// Write the constraint description to a MessageWriter
/// </summary>
/// <param name="writer">The writer on which the description is displayed</param>
public override void WriteDescriptionTo(MessageWriter writer)
{
if (baseConstraint == null)
writer.WritePredicate("an exception");
else
baseConstraint.WriteDescriptionTo(writer);
}
示例9: WriteActualValueTo
public override void WriteActualValueTo(MessageWriter writer)
{
if (actual is IEnumerable<IField> && ((IEnumerable<IField>)actual).Count() > 0)
base.WriteActualValueTo(writer);
else
writer.WriteActualValue(new WriterHelper.NothingFoundMessage());
}
示例10: 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);
}
}
}
示例11: WriteDescriptionTo
/// <summary>
/// Write the constraint description to a MessageWriter
/// </summary>
/// <param name="writer">The writer on which the description is displayed</param>
public override void WriteDescriptionTo(MessageWriter writer)
{
writer.WritePredicate("String matching");
writer.WriteExpectedValue(this.expected);
if (this.caseInsensitive)
writer.WriteModifier("ignoring case");
}
示例12: WriteMessageTo
public override void WriteMessageTo(MessageWriter writer)
{
foreach (var pair in _Members.Where(item => !item.Value.IsSuccess))
{
var member = pair.Key;
var result = pair.Value;
var type = "void";
if (member is PropertyInfo)
{
type = (member as PropertyInfo).PropertyType.Name;
}
if (member is FieldInfo)
{
type = (member as FieldInfo).FieldType.Name;
}
writer.Write(
"{0}Property [{1} {2}.{3}]\n",
_Prefix,
type,
member.DeclaringType.Name,
member.Name
);
var twin = result as TwinConstraintResult;
if (twin != null)
{
twin._Prefix = string.Concat(_Prefix, "-- ");
}
result.WriteMessageTo(writer);
}
}
示例13: WriteDescriptionTo
/// <summary>
/// Write the constraint description to a MessageWriter
/// </summary>
/// <param name="writer">The writer on which the description is displayed</param>
public override void WriteDescriptionTo(MessageWriter writer)
{
//if (actual is string)
// writer.WriteExpected(string.Empty);
//else
writer.Write("<empty>");
}
示例14: WriteDescriptionTo
public override void WriteDescriptionTo(MessageWriter writer)
{
this.actual = "Found " + differencies.Count + " differencies between two objects";
differencies.ForEach(s =>
{
writer.WriteMessageLine(s);
});
}
示例15: WriteDescriptionTo
public override void WriteDescriptionTo(MessageWriter writer)
{
writer.Write("[");
leftConstraint.WriteDescriptionTo(writer);
writer.WriteConnector("AND");
rightConstraint.WriteDescriptionTo(writer);
writer.Write("]");
}