Table of Contents

Class MsgUtils

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

Static methods used in creating messages

public static class MsgUtils
Inheritance
MsgUtils
Inherited Members

Methods

ClipExpectedAndActual(ref string, ref string, int, int)

Clip the expected and actual strings in a coordinated fashion, so that they may be displayed together.

public static void ClipExpectedAndActual(ref string expected, ref string actual, int maxDisplayLength, int mismatch)

Parameters

expected string
actual string
maxDisplayLength int
mismatch int

ClipString(string, int, int)

Clip a string to a given length, starting at a particular offset, returning the clipped string with ellipses representing the removed parts

public static string ClipString(string s, int maxStringLength, int clipStart)

Parameters

s string

The string to be clipped

maxStringLength int

The maximum permitted length of the result string

clipStart int

The point at which to start clipping

Returns

string

The clipped string

EscapeControlChars(string)

Converts any control characters in a string to their escaped representation.

public static string EscapeControlChars(string s)

Parameters

s string

The string to be converted

Returns

string

The converted string

FindMismatchPosition(string, string, int, bool)

Shows the position two strings start to differ. Comparison starts at the start index.

public static int FindMismatchPosition(string expected, string actual, int istart, bool ignoreCase)

Parameters

expected string

The expected string

actual string

The actual string

istart int

The index in the strings at which comparison should start

ignoreCase bool

Boolean indicating whether case should be ignored

Returns

int

-1 if no mismatch found, or the index where mismatch found

FormatCollection(IEnumerable, long, int)

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

public static string FormatCollection(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

Returns

string

FormatValue(object)

Formats text to represent a generalized value.

public static string FormatValue(object val)

Parameters

val object

The value

Returns

string

The formatted text

GetArrayIndicesAsString(int[])

Return the a string representation for a set of indices into an array

public static string GetArrayIndicesAsString(int[] indices)

Parameters

indices int[]

Array of indices for which a string is needed

Returns

string

GetArrayIndicesFromCollectionIndex(IEnumerable, long)

Get an array of indices representing the point in a collection or array corresponding to a single int index into the collection.

public static int[] GetArrayIndicesFromCollectionIndex(IEnumerable collection, long index)

Parameters

collection IEnumerable

The collection to which the indices apply

index long

Index in the collection

Returns

int[]

Array of indices

GetTypeRepresentation(object)

Returns the representation of a type as used in NUnitLite. This is the same as Type.ToString() except for arrays, which are displayed with their declared sizes.

public static string GetTypeRepresentation(object obj)

Parameters

obj object

Returns

string