MessageWriter
MessageWriter is the abstract base for classes that write
constraint descriptions and messages in some form. The
class has separate methods for writing various components
of a message, allowing implementations to tailor the
presentation as needed.
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class MessageWriter : StringWriter
{
public abstract int MaxLineLength { get; set; }
protected MessageWriter()
: base(CultureInfo.InvariantCulture)
{
}
public void WriteMessageLine(string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args)
{
WriteMessageLine(0, message, args);
}
public abstract void WriteMessageLine(int level, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args);
public abstract void DisplayDifferences(ConstraintResult result);
[System.Runtime.CompilerServices.NullableContext(2)]
public abstract void DisplayDifferences(object expected, object actual);
[System.Runtime.CompilerServices.NullableContext(2)]
public abstract void DisplayDifferences(object expected, object actual, Tolerance tolerance);
public abstract void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase, bool clipping);
public virtual void DisplayStringDifferences(string expected, string actual, int mismatchExpected, int mismatchActual, bool ignoreCase, bool ignoreWhiteSpace, bool clipping)
{
if (ignoreWhiteSpace && mismatchExpected != mismatchActual)
throw new NotImplementedException("Please override to show difference with 'ignoreWhiteSpace'");
DisplayStringDifferences(expected, actual, mismatchExpected, ignoreCase, clipping);
}
[System.Runtime.CompilerServices.NullableContext(2)]
public abstract void WriteActualValue(object actual);
[System.Runtime.CompilerServices.NullableContext(2)]
public abstract void WriteValue(object val);
public abstract void WriteCollectionElements(IEnumerable collection, long start, int max);
}
}