Table of Contents

Class TextMessageWriter

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

TextMessageWriter writes constraint descriptions and messages in displayable form as a text stream. It tailors the display of individual message components to form the standard message format of NUnit assertion failure messages.

public class TextMessageWriter : MessageWriter, IDisposable, IAsyncDisposable
Inheritance
TextMessageWriter
Implements
Inherited Members

Constructors

TextMessageWriter()

Construct a TextMessageWriter

public TextMessageWriter()

TextMessageWriter(string, params object[])

Construct a TextMessageWriter, specifying a user message and optional formatting arguments.

public TextMessageWriter(string userMessage, params object[] args)

Parameters

userMessage string
args object[]

Fields

Pfx_Actual

Prefix used for the actual value line of a message

public static readonly string Pfx_Actual

Field Value

string

Pfx_Expected

Prefix used for the expected value line of a message

public static readonly string Pfx_Expected

Field Value

string

PrefixLength

Length of a message prefix

public static readonly int PrefixLength

Field Value

int

Properties

MaxLineLength

Gets or sets the maximum line length for this writer

public override int MaxLineLength { get; set; }

Property Value

int

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 override void DisplayDifferences(ConstraintResult result)

Parameters

result ConstraintResult

The result of the constraint that failed

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 override void DisplayDifferences(object expected, object actual)

Parameters

expected object

The expected value

actual object

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.

public override void DisplayDifferences(object expected, object actual, Tolerance tolerance)

Parameters

expected object

The expected value

actual object

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.

public override void DisplayStringDifferences(string expected, string actual, int mismatch, bool ignoreCase, bool clipping)

Parameters

expected string

The expected string value

actual string

The actual string value

mismatch int

The point at which the strings don't match or -1

ignoreCase bool

If true, case is ignored in string comparisons

clipping bool

If true, clip the strings to fit the max line length

WriteActualValue(object)

Writes the text for an actual value.

public override void WriteActualValue(object actual)

Parameters

actual object

The actual value.

WriteCollectionElements(IEnumerable, long, int)

Writes the text for a collection value, starting at a particular point, to a max length

public override void WriteCollectionElements(IEnumerable collection, long start, int max)

Parameters

collection IEnumerable

The collection containing elements to write.

start long

The starting point of the elements to write

max int

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 givel indentation level.

public override void WriteMessageLine(int level, string message, params object[] args)

Parameters

level int

The indentation level of the message

message string

The message to be written

args object[]

Any arguments used in formatting the message

WriteValue(object)

Writes the text for a generalized value.

public override void WriteValue(object val)

Parameters

val object

The value.