Table of Contents

Class StringAssert

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Basic Asserts on strings.

public class StringAssert
Inheritance
StringAssert
Inherited Members

Constructors

StringAssert()

public StringAssert()

Methods

AreEqualIgnoringCase(string, string)

Asserts that two strings are equal, without regard to case.

public static void AreEqualIgnoringCase(string expected, string actual)

Parameters

expected string

The expected string

actual string

The actual string

AreEqualIgnoringCase(string, string, string)

Asserts that two strings are equal, without regard to case.

public static void AreEqualIgnoringCase(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The actual string

message string

The message to display in case of failure

AreEqualIgnoringCase(string, string, string, params object[])

Asserts that two strings are equal, without regard to case.

public static void AreEqualIgnoringCase(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The actual string

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

AreNotEqualIgnoringCase(string, string)

Asserts that two strings are not equal, without regard to case.

public static void AreNotEqualIgnoringCase(string expected, string actual)

Parameters

expected string

The expected string

actual string

The actual string

AreNotEqualIgnoringCase(string, string, string)

Asserts that two strings are Notequal, without regard to case.

public static void AreNotEqualIgnoringCase(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The actual string

message string

The message to display in case of failure

AreNotEqualIgnoringCase(string, string, string, params object[])

Asserts that two strings are not equal, without regard to case.

public static void AreNotEqualIgnoringCase(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The actual string

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

Contains(string, string)

Asserts that a string is found within another string.

public static void Contains(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

Contains(string, string, string)

Asserts that a string is found within another string.

public static void Contains(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

Contains(string, string, string, params object[])

Asserts that a string is found within another string.

public static void Contains(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

DoesNotContain(string, string)

Asserts that a string is found within another string.

public static void DoesNotContain(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

DoesNotContain(string, string, string)

Asserts that a string is found within another string.

public static void DoesNotContain(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

DoesNotContain(string, string, string, params object[])

Asserts that a string is not found within another string.

public static void DoesNotContain(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

DoesNotEndWith(string, string)

Asserts that a string does not end with another string.

public static void DoesNotEndWith(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

DoesNotEndWith(string, string, string)

Asserts that a string does not end with another string.

public static void DoesNotEndWith(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

DoesNotEndWith(string, string, string, params object[])

Asserts that a string does not end with another string.

public static void DoesNotEndWith(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

DoesNotMatch(string, string)

Asserts that a string does not match an expected regular expression pattern.

public static void DoesNotMatch(string pattern, string actual)

Parameters

pattern string

The regex pattern to be used

actual string

The actual string

DoesNotMatch(string, string, string)

Asserts that a string does not match an expected regular expression pattern.

public static void DoesNotMatch(string pattern, string actual, string message)

Parameters

pattern string

The regex pattern to be used

actual string

The actual string

message string

The message to display in case of failure

DoesNotMatch(string, string, string, params object[])

Asserts that a string does not match an expected regular expression pattern.

public static void DoesNotMatch(string pattern, string actual, string message, params object[] args)

Parameters

pattern string

The regex pattern to be used

actual string

The actual string

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

DoesNotStartWith(string, string)

Asserts that a string does not start with another string.

public static void DoesNotStartWith(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

DoesNotStartWith(string, string, string)

Asserts that a string does not start with another string.

public static void DoesNotStartWith(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

DoesNotStartWith(string, string, string, params object[])

Asserts that a string does not start with another string.

public static void DoesNotStartWith(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

EndsWith(string, string)

Asserts that a string ends with another string.

public static void EndsWith(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

EndsWith(string, string, string)

Asserts that a string ends with another string.

public static void EndsWith(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

EndsWith(string, string, string, params object[])

Asserts that a string ends with another string.

public static void EndsWith(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

IsMatch(string, string)

Asserts that a string matches an expected regular expression pattern.

public static void IsMatch(string pattern, string actual)

Parameters

pattern string

The regex pattern to be matched

actual string

The actual string

IsMatch(string, string, string)

Asserts that a string matches an expected regular expression pattern.

public static void IsMatch(string pattern, string actual, string message)

Parameters

pattern string

The regex pattern to be matched

actual string

The actual string

message string

The message to display in case of failure

IsMatch(string, string, string, params object[])

Asserts that a string matches an expected regular expression pattern.

public static void IsMatch(string pattern, string actual, string message, params object[] args)

Parameters

pattern string

The regex pattern to be matched

actual string

The actual string

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message

ReferenceEquals(object, object)

override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert.

public static void ReferenceEquals(object a, object b)

Parameters

a object
b object

StartsWith(string, string)

Asserts that a string starts with another string.

public static void StartsWith(string expected, string actual)

Parameters

expected string

The expected string

actual string

The string to be examined

StartsWith(string, string, string)

Asserts that a string starts with another string.

public static void StartsWith(string expected, string actual, string message)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

StartsWith(string, string, string, params object[])

Asserts that a string starts with another string.

public static void StartsWith(string expected, string actual, string message, params object[] args)

Parameters

expected string

The expected string

actual string

The string to be examined

message string

The message to display in case of failure

args object[]

Arguments used in formatting the message