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
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
stringThe string to be clipped
maxStringLength
intThe maximum permitted length of the result string
clipStart
intThe 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
stringThe 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
stringThe expected string
actual
stringThe actual string
istart
intThe index in the strings at which comparison should start
ignoreCase
boolBoolean 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
IEnumerableThe collection containing elements to write.
start
longThe starting point of the elements to write
max
intThe maximum number of elements to write
Returns
FormatValue(object)
Formats text to represent a generalized value.
public static string FormatValue(object val)
Parameters
val
objectThe 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
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
IEnumerableThe collection to which the indices apply
index
longIndex 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