Class MessageWriter
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
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.
public abstract class MessageWriter : StringWriter, IDisposable, IAsyncDisposable
- Inheritance
-
MessageWriter
- Implements
- Derived
- Inherited Members
Constructors
MessageWriter()
Construct a MessageWriter given a culture
protected MessageWriter()
Properties
MaxLineLength
Abstract method to get the max line length
public abstract int MaxLineLength { get; set; }
Property Value
Methods
DisplayDifferences(ConstraintResult)
Display Expected and Actual lines for a constraint. This is called by MessageWriter's default implementation of WriteMessageTo and provides the generic two-line display.
public abstract void DisplayDifferences(ConstraintResult result)
Parameters
result
ConstraintResultThe failing constraint result
DisplayDifferences(object, object)
Display Expected and Actual lines for given _values. This method may be called by constraints that need more control over the display of actual and expected _values than is provided by the default implementation.
public abstract void DisplayDifferences(object expected, object actual)
Parameters
DisplayDifferences(object, object, Tolerance)
Display Expected and Actual lines for given _values, including a tolerance value on the Expected line.
public abstract void DisplayDifferences(object expected, object actual, Tolerance tolerance)
Parameters
expected
objectThe expected value
actual
objectThe actual value causing the failure
tolerance
ToleranceThe tolerance within which the test was made
DisplayStringDifferences(string, string, int, bool, bool)
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 void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase, bool clipping)
Parameters
expected
stringThe expected string value
actual
stringThe actual string value
mismatch
intThe point at which the strings don't match or -1
ignoreCase
boolIf true, case is ignored in locating the point where the strings differ
clipping
boolIf true, the strings should be clipped to fit the line
WriteActualValue(object)
Writes the text for an actual value.
public abstract void WriteActualValue(object actual)
Parameters
actual
objectThe actual value.
WriteCollectionElements(IEnumerable, long, int)
Writes the text for a collection value, starting at a particular point, to a max length
public abstract void WriteCollectionElements(IEnumerable collection, long start, int max)
Parameters
collection
IEnumerableThe collection containing elements to write.
start
longThe starting point of the elements to write
max
intThe maximum number of elements to write
WriteMessageLine(int, string, params object[])
Method to write single line message with optional args, usually written to precede the general failure message, at a givel indentation level.
public abstract void WriteMessageLine(int level, string message, params object[] args)
Parameters
level
intThe indentation level of the message
message
stringThe message to be written
args
object[]Any arguments used in formatting the message
WriteMessageLine(string, params object[])
Method to write single line message with optional args, usually written to precede the general failure message.
public void WriteMessageLine(string message, params object[] args)
Parameters
WriteValue(object)
Writes the text for a generalized value.
public abstract void WriteValue(object val)
Parameters
val
objectThe value.