Class 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.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public abstract class MessageWriter : StringWriter, IDisposable, IAsyncDisposable
Constructors
View SourceMessageWriter()
Construct a MessageWriter given a culture
Declaration
protected MessageWriter()
Properties
View SourceMaxLineLength
Abstract method to get the max line length
Declaration
public abstract int MaxLineLength { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
View SourceDisplayDifferences(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.
Declaration
public abstract void DisplayDifferences(ConstraintResult result)
Parameters
Type | Name | Description |
---|---|---|
ConstraintResult | result | The 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.
Declaration
public abstract void DisplayDifferences(object? expected, object? actual)
Parameters
Type | Name | Description |
---|---|---|
object | expected | The expected value |
object | actual | The actual value causing the failure |
DisplayDifferences(object?, object?, Tolerance?)
Display Expected and Actual lines for given values, including a tolerance value on the Expected line.
Declaration
public abstract void DisplayDifferences(object? expected, object? actual, Tolerance? tolerance)
Parameters
Type | Name | Description |
---|---|---|
object | expected | The expected value |
object | actual | The actual value causing the failure |
Tolerance | tolerance | The 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.
Declaration
public abstract void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase, bool clipping)
Parameters
Type | Name | Description |
---|---|---|
string | expected | The expected string value |
string | actual | The actual string value |
int | mismatch | The point in |
bool | ignoreCase | If true, case is ignored in locating the point where the strings differ |
bool | clipping | If true, the strings should be clipped to fit the line |
DisplayStringDifferences(string, string, int, int, bool, 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.
Declaration
public virtual void DisplayStringDifferences(string expected, string actual, int mismatchExpected, int mismatchActual, bool ignoreCase, bool ignoreWhiteSpace, bool clipping)
Parameters
Type | Name | Description |
---|---|---|
string | expected | The expected string value |
string | actual | The actual string value |
int | mismatchExpected | The point in |
int | mismatchActual | The point in |
bool | ignoreCase | If true, case is ignored in locating the point where the strings differ |
bool | ignoreWhiteSpace | If true, white space is ignored in locating the point where the strings differ |
bool | clipping | If true, the strings should be clipped to fit the line |
WriteActualValue(object?)
Writes the text for an actual value.
Declaration
public abstract void WriteActualValue(object? actual)
Parameters
Type | Name | Description |
---|---|---|
object | actual | The actual value. |
WriteCollectionElements(IEnumerable, long, int)
Writes the text for a collection value, starting at a particular point, to a max length
Declaration
public abstract void WriteCollectionElements(IEnumerable collection, long start, int max)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable | collection | The collection containing elements to write. |
long | start | The starting point of the elements to write |
int | max | The 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 given indentation level.
Declaration
public abstract void WriteMessageLine(int level, string message, params object?[]? args)
Parameters
Type | Name | Description |
---|---|---|
int | level | The indentation level of the message |
string | message | The message to be written |
object[] | args | 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.
Declaration
public void WriteMessageLine(string message, params object?[]? args)
Parameters
Type | Name | Description |
---|---|---|
string | message | The message to be written |
object[] | args | Any arguments used in formatting the message |
WriteValue(object?)
Writes the text for a generalized value.
Declaration
public abstract void WriteValue(object? val)
Parameters
Type | Name | Description |
---|---|---|
object | val | The value. |