NUnit.Framework

An NDoc Documented Class Library

NUnit.Framework Namespace

Classes

Class | Description
Assert | A set of Assert methods
Assertion | Obsolete. A set of Assert methods.
AssertionException | Thrown when an assertion failed.
AssertionFailureMessage | Summary description for AssertionFailureMessage.
CategoryAttribute | Summary description for CategoryAttribute.
ExpectedExceptionAttribute | ExpectedAttributeException.
ExplicitAttribute | ExplicitAttribute marks a test or test fixture so that it will only be run if explicitly executed from the gui or command line or if it is included by use of a filter. The test will not be run simply because an enclosing suite is run.
IgnoreAttribute | IgnoreAttribute.
IgnoreException | Thrown when an assertion failed.
SetUpAttribute | SetUpAttribute.
SuiteAttribute | SuiteAttribute.
TearDownAttribute | TearDownAttribute.
TestAttribute | Adding this attribute to a method within a class makes the method callable from the NUnit test runner. There is a property called Description which is optional which you can provide a more detailed test description. This class cannot be inherited.
TestCase | Obsolete. TestFixture
TestFixtureAttribute | TestFixtureAttribute
TestFixtureSetUpAttribute | TestFixtureSetUpAttribute
TestFixtureTearDownAttribute | TestFixtureTearDownAttribute


Assert Class

A set of Assert methods

For a list of all members of this type, see Assert Members.

System.Object
Assert

public class Assert

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

Assert Members | NUnit.Framework Namespace


Assert Members

Assert overview

Public Static Properties

Counter Gets the number of assertions executed so far and resets the counter to zero.

Public Static Methods

AreEqual | Overloaded. Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.
AreSame | Overloaded. Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.
Equals | Overloaded. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function.
Fail | Overloaded. Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.
Ignore | Overloaded. Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.
IsFalse | Overloaded. Asserts that a condition is false. If the condition is true the method throws an AssertionException.
IsNotNull Overloaded. Verifies that the object that is passed in is not equal to
null
If the object is not
null
then an AssertionException is thrown.
IsNull Overloaded. Verifies that the object that is passed in is equal to
null
If the object is
null
then an AssertionException is thrown.
IsTrue | Overloaded. Asserts that a condition is true. If the condition is false the method throws an AssertionException.
ReferenceEquals | override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert.

Protected Static Methods

FailArraysNotEqual | This method is called when two arrays have been compared and found to be different. This prints a nice message to the screen.
FailNotEquals | This method is called when two objects have been compared and found to be different. This prints a nice message to the screen.
FailNotSame | This method is called when the two objects are not the same.
IsNumericType | Checks the type of the object, returning true if the object is a numeric type.
ObjectsEqual | Used to compare two objects. Two nulls are equal and null is not equal to non-null. Comparisons between the same numeric types are fine (Int32 to Int32, or Int64 to Int64), but the Equals method fails across different types so we use ToString and compare the results.

Public Instance Methods

Equals (inherited from Object) | Overloaded.
GetHashCode (inherited from Object) |
GetType (inherited from Object) |
ToString (inherited from Object) |

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

Assert Class | NUnit.Framework Namespace


Assert Properties

The properties of the Assert class are listed below. For a complete list of Assert class members, see the Assert Members topic.

Public Static Properties

Counter Gets the number of assertions executed so far and resets the counter to zero.

See Also

Assert Class | NUnit.Framework Namespace


Assert.Counter Property

Gets the number of assertions executed so far and resets the counter to zero.

public static int Counter {get;}

See Also

Assert Class | NUnit.Framework Namespace


Assert Methods

The methods of the Assert class are listed below. For a complete list of Assert class members, see the Assert Members topic.

Public Static Methods

AreEqual | Overloaded. Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.
AreSame | Overloaded. Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.
Equals | Overloaded. The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function.
Fail | Overloaded. Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.
Ignore | Overloaded. Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.
IsFalse | Overloaded. Asserts that a condition is false. If the condition is true the method throws an AssertionException.
IsNotNull Overloaded. Verifies that the object that is passed in is not equal to
null
If the object is not
null
then an AssertionException is thrown.
IsNull Overloaded. Verifies that the object that is passed in is equal to
null
If the object is
null
then an AssertionException is thrown.
IsTrue | Overloaded. Asserts that a condition is true. If the condition is false the method throws an AssertionException.
ReferenceEquals | override the default ReferenceEquals to throw an AssertionException. This implementation makes sure there is no mistake in calling this function as part of Assert.

Protected Static Methods

FailArraysNotEqual | This method is called when two arrays have been compared and found to be different. This prints a nice message to the screen.
FailNotEquals | This method is called when two objects have been compared and found to be different. This prints a nice message to the screen.
FailNotSame | This method is called when the two objects are not the same.
IsNumericType | Checks the type of the object, returning true if the object is a numeric type.
ObjectsEqual | Used to compare two objects. Two nulls are equal and null is not equal to non-null. Comparisons between the same numeric types are fine (Int32 to Int32, or Int64 to Int64), but the Equals method fails across different types so we use ToString and compare the results.

Public Instance Methods

Equals (inherited from Object) | Overloaded.
GetHashCode (inherited from Object) |
GetType (inherited from Object) |
ToString (inherited from Object) |

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

Assert Class | NUnit.Framework Namespace


AreEqual Method

An NDoc Documented Class Library

Assert.AreEqual Method

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

Overload List

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(Array,Array);

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(Array,Array,string);

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(Array,Array,string,params object[]);

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(decimal,decimal);

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(decimal,decimal,string);

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(decimal,decimal,string,params object[]);

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(double,double,double);

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(double,double,double,string);

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(double,double,double,string,params object[]);

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(int,int);

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(int,int,string);

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(int,int,string,params object[]);

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AreEqual(object,object);

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AreEqual(object,object,string);

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. Arrays are compared by comparing each element using the same rules. If they are not equal an AssertionException is thrown.

public static void AreEqual(object,object,string,params object[]);

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(float,float,float);

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(float,float,float,string);

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(float,float,float,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.AreEqual Method (Array, Array)

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(
Array expected,
Array actual
);

Parameters

expected
The expected value
actual
The actual value

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Array, Array, String)

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(
Array expected,
Array actual,
string message
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Array, Array, String, Object[])

Verifies that two arrays are equal. If they are not, then an AssertionException is thrown.

public static void AreEqual(
Array expected,
Array actual,
string message,
params object[] args
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Decimal, Decimal)

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
decimal expected,
decimal actual
);

Parameters

expected
The expected value
actual
The actual value

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Decimal, Decimal, String)

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
decimal expected,
decimal actual,
string message
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Decimal, Decimal, String, Object[])

Verifies that two decimals are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
decimal expected,
decimal actual,
string message,
params object[] args
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Double, Double, Double)

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
double expected,
double actual,
double delta
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Double, Double, Double, String)

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
double expected,
double actual,
double delta,
string message
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual
message
The message that will be printed on failure

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Double, Double, Double, String, Object[])

Verifies that two doubles are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
double expected,
double actual,
double delta,
string message,
params object[] args
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual
message
The message that will be printed on failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Int32, Int32)

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
int expected,
int actual
);

Parameters

expected
The expected value
actual
The actual value

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Int32, Int32, String)

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
int expected,
int actual,
string message
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Int32, Int32, String, Object[])

Verifies that two ints are equal. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
int expected,
int actual,
string message,
params object[] args
);

Parameters

expected
The expected value
actual
The actual value
message
The message printed out upon failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Object, Object)

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AreEqual(
object expected,
object actual
);

Parameters

expected
The value that is expected
actual
The actual value

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Object, Object, String)

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AreEqual(
object expected,
object actual,
string message
);

Parameters

expected
The value that is expected
actual
The actual value
message
The message to display if objects are not equal

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Object, Object, String, Object[])

Verifies that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. All non-numeric types are compared by using the Equals method. Arrays are compared by comparing each element using the same rules. If they are not equal an AssertionException is thrown.

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

Parameters

expected
The value that is expected
actual
The actual value
message
The message to display if objects are not equal
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Single, Single, Single)

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
float expected,
float actual,
float delta
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Single, Single, Single, String)

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
float expected,
float actual,
float delta,
string message
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual
message
The message printed out upon failure

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


Assert.AreEqual Method (Single, Single, Single, String, Object[])

Verifies that two floats are equal considering a delta. If the expected value is infinity then the delta value is ignored. If they are not equals then an AssertionException is thrown.

public static void AreEqual(
float expected,
float actual,
float delta,
string message,
params object[] args
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual
message
The message printed out upon failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreEqual Overload List


AreSame Method

An NDoc Documented Class Library

Assert.AreSame Method

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

Overload List

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AreSame(object,object);

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AreSame(object,object,string);

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AreSame(object,object,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.AreSame Method (Object, Object)

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AreSame(
object expected,
object actual
);

Parameters

expected
The expected object
actual
The actual object

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreSame Overload List


Assert.AreSame Method (Object, Object, String)

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AreSame(
object expected,
object actual,
string message
);

Parameters

expected
The expected object
actual
The actual object
message
The message to be printed when the object is null

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreSame Overload List


Assert.AreSame Method (Object, Object, String, Object[])

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

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

Parameters

expected
The expected object
actual
The actual object
message
The message to be printed when the two objects are not the same object.
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.AreSame Overload List


Equals Method

An NDoc Documented Class Library

Assert.Equals Method

The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function.

Overload List

Inherited from Object.

public virtual bool Equals(object);

The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function.

new public static bool Equals(object,object);

See Also

Assert Class | NUnit.Framework Namespace


Assert.Equals Method (Object, Object)

The Equals method throws an AssertionException. This is done to make sure there is no mistake by calling this function.

new public static bool Equals(
object a,
object b
);

Parameters

a
b

See Also

Assert Class | NUnit.Framework Namespace | Assert.Equals Overload List


Fail Method

An NDoc Documented Class Library

Assert.Fail Method

Throws an AssertionException. This is used by the other Assert functions.

Overload List

Throws an AssertionException. This is used by the other Assert functions.

public static void Fail();

Throws an AssertionException with the message that is passed in. This is used by the other Assert functions.

public static void Fail(string);

Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.

public static void Fail(string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.Fail Method ()

Throws an AssertionException. This is used by the other Assert functions.

public static void Fail();

See Also

Assert Class | NUnit.Framework Namespace | Assert.Fail Overload List


Assert.Fail Method (String)

Throws an AssertionException with the message that is passed in. This is used by the other Assert functions.

public static void Fail(
string message
);

Parameters

message
The message to initialize the AssertionException with.

See Also

Assert Class | NUnit.Framework Namespace | Assert.Fail Overload List


Assert.Fail Method (String, Object[])

Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.

public static void Fail(
string message,
params object[] args
);

Parameters

message
The message to initialize the AssertionException with.
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.Fail Overload List


Assert.FailArraysNotEqual Method

This method is called when two arrays have been compared and found to be different. This prints a nice message to the screen.

protected static void FailArraysNotEqual(
int index,
Array expected,
Array actual,
string message,
params object[] args
);

Parameters

index
The index at which the failure occured
expected
The expected array
actual
The actual array
message
The message that is to be printed prior to the comparison failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace


Assert.FailNotEquals Method

This method is called when two objects have been compared and found to be different. This prints a nice message to the screen.

protected static void FailNotEquals(
object expected,
object actual,
string message,
params object[] args
);

Parameters

expected
The expected object
actual
The actual object
message
The message that is to be printed prior to the comparison failure
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace


Assert.FailNotSame Method

This method is called when the two objects are not the same.

protected static void FailNotSame(
object expected,
object actual,
string message,
params object[] args
);

Parameters

expected
The expected object
actual
The actual object
message
The message to be printed on the screen
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace


Ignore Method

An NDoc Documented Class Library

Assert.Ignore Method

Throws an IgnoreException. This causes the test to be reported as ignored.

Overload List

Throws an IgnoreException. This causes the test to be reported as ignored.

public static void Ignore();

Throws an IgnoreException with the message that is passed in. This causes the test to be reported as ignored.

public static void Ignore(string);

Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.

public static void Ignore(string,object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.Ignore Method ()

Throws an IgnoreException. This causes the test to be reported as ignored.

public static void Ignore();

Parameters

See Also

Assert Class | NUnit.Framework Namespace | Assert.Ignore Overload List


Assert.Ignore Method (String)

Throws an IgnoreException with the message that is passed in. This causes the test to be reported as ignored.

public static void Ignore(
string message
);

Parameters

message
The message to initialize the AssertionException with.

See Also

Assert Class | NUnit.Framework Namespace | Assert.Ignore Overload List


Assert.Ignore Method (String, Object[])

Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.

public static void Ignore(
string message,
object[] args
);

Parameters

message
The message to initialize the AssertionException with.
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.Ignore Overload List


IsFalse Method

An NDoc Documented Class Library

Assert.IsFalse Method

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

Overload List

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(bool);

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(bool,string);

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(bool,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.IsFalse Method (Boolean)

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(
bool condition
);

Parameters

condition
The evaluated condition

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsFalse Overload List


Assert.IsFalse Method (Boolean, String)

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(
bool condition,
string message
);

Parameters

condition
The evaluated condition
message
The message to display if the condition is true

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsFalse Overload List


Assert.IsFalse Method (Boolean, String, Object[])

Asserts that a condition is false. If the condition is true the method throws an AssertionException.

public static void IsFalse(
bool condition,
string message,
params object[] args
);

Parameters

condition
The evaluated condition
message
The message to display if the condition is true
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsFalse Overload List


IsNotNull Method

An NDoc Documented Class Library

Assert.IsNotNull Method

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

Overload List

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(object);

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(object,string);

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(object,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.IsNotNull Method (Object)

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(
object anObject
);

Parameters

anObject
The object that is to be tested

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNotNull Overload List


Assert.IsNotNull Method (Object, String)

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(
object anObject,
string message
);

Parameters

anObject
The object that is to be tested
message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNotNull Overload List


Assert.IsNotNull Method (Object, String, Object[])

Verifies that the object that is passed in is not equal to

null
If the object is not
null
then an AssertionException is thrown.

public static void IsNotNull(
object anObject,
string message,
params object[] args
);

Parameters

anObject
The object that is to be tested
message
The message to be printed when the object is null
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNotNull Overload List


IsNull Method

An NDoc Documented Class Library

Assert.IsNull Method

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

Overload List

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(object);

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(object,string);

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(object,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.IsNull Method (Object)

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(
object anObject
);

Parameters

anObject
The object that is to be tested

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNull Overload List


Assert.IsNull Method (Object, String)

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(
object anObject,
string message
);

Parameters

anObject
The object that is to be tested
message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNull Overload List


Assert.IsNull Method (Object, String, Object[])

Verifies that the object that is passed in is equal to

null
If the object is
null
then an AssertionException is thrown.

public static void IsNull(
object anObject,
string message,
params object[] args
);

Parameters

anObject
The object that is to be tested
message
The message to be printed when the object is not null
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsNull Overload List


Assert.IsNumericType Method

Checks the type of the object, returning true if the object is a numeric type.

protected static bool IsNumericType(
object obj
);

Parameters

obj
The object to check

Return Value

true if the object is a numeric type

See Also

Assert Class | NUnit.Framework Namespace


IsTrue Method

An NDoc Documented Class Library

Assert.IsTrue Method

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

Overload List

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(bool);

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(bool,string);

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(bool,string,params object[]);

See Also

Assert Class | NUnit.Framework Namespace


Assert.IsTrue Method (Boolean)

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(
bool condition
);

Parameters

condition
The evaluated condition

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsTrue Overload List


Assert.IsTrue Method (Boolean, String)

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(
bool condition,
string message
);

Parameters

condition
The evaluated condition
message
The message to display if the condition is false

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsTrue Overload List


Assert.IsTrue Method (Boolean, String, Object[])

Asserts that a condition is true. If the condition is false the method throws an AssertionException.

public static void IsTrue(
bool condition,
string message,
params object[] args
);

Parameters

condition
The evaluated condition
message
The message to display if the condition is false
args
Arguments to be used in formatting the message

See Also

Assert Class | NUnit.Framework Namespace | Assert.IsTrue Overload List


Assert.ObjectsEqual Method

Used to compare two objects. Two nulls are equal and null is not equal to non-null. Comparisons between the same numeric types are fine (Int32 to Int32, or Int64 to Int64), but the Equals method fails across different types so we use ToString and compare the results.

protected static bool ObjectsEqual(
object expected,
object actual
);

Parameters

expected
actual

Return Value

See Also

Assert Class | NUnit.Framework Namespace


Assert.ReferenceEquals Method

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

new public static void ReferenceEquals(
object a,
object b
);

Parameters

a
b

See Also

Assert Class | NUnit.Framework Namespace


Assertion Class

NOTE: This class is now obsolete.

Use Assert class instead

A set of Assert methods.

For a list of all members of this type, see Assertion Members.

System.Object
Assertion

public class Assertion

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

Assertion Members | NUnit.Framework Namespace


Assertion Members

Assertion overview

Public Static Methods

Assert | Overloaded. Asserts that a condition is true. If it isn't it throws an AssertionException.
AssertEquals | Overloaded. /// Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.
AssertNotNull | Overloaded. Asserts that an object isn't null.
AssertNull | Overloaded. Asserts that an object is null.
AssertSame | Overloaded. Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.
Fail | Overloaded. Fails a test with no message.

Public Instance Constructors

Assertion Constructor Initializes a new instance of the Assertion class.

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

Assertion Class | NUnit.Framework Namespace


Assertion Constructor

Initializes a new instance of the Assertion class.

public Assertion();

See Also

Assertion Class | NUnit.Framework Namespace


Assertion Methods

The methods of the Assertion class are listed below. For a complete list of Assertion class members, see the Assertion Members topic.

Public Static Methods

Assert | Overloaded. Asserts that a condition is true. If it isn't it throws an AssertionException.
AssertEquals | Overloaded. /// Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.
AssertNotNull | Overloaded. Asserts that an object isn't null.
AssertNull | Overloaded. Asserts that an object is null.
AssertSame | Overloaded. Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.
Fail | Overloaded. Fails a test with no message.

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

Assertion Class | NUnit.Framework Namespace


Assert Method

An NDoc Documented Class Library

Assertion.Assert Method

Asserts that a condition is true. If it isn't it throws an AssertionException.

Overload List

Asserts that a condition is true. If it isn't it throws an AssertionException.

public static void Assert(bool);

Asserts that a condition is true. If it isn't it throws an AssertionException.

public static void Assert(string,bool);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.Assert Method (Boolean)

Asserts that a condition is true. If it isn't it throws an AssertionException.

public static void Assert(
bool condition
);

Parameters

condition
The evaluated condition

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.Assert Overload List


Assertion.Assert Method (String, Boolean)

Asserts that a condition is true. If it isn't it throws an AssertionException.

public static void Assert(
string message,
bool condition
);

Parameters

message
The message to display is the condition is false
condition
The evaluated condition

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.Assert Overload List


AssertEquals Method

An NDoc Documented Class Library

Assertion.AssertEquals Method

/// Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

Overload List

/// Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(double,double,double);

Asserts that two ints are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(int,int);

Asserts that two objects are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(object,object);

/// Asserts that two singles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(float,float,float);

Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(string,double,double,double);

Asserts that two ints are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(string,int,int);

Asserts that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. Numeric types are compared via string comparision on their contents to avoid problems comparing values between different types. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AssertEquals(string,object,object);

Asserts that two floats are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(string,float,float,float);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.AssertEquals Method (Double, Double, Double)

/// Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(
double expected,
double actual,
double delta
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (Int32, Int32)

Asserts that two ints are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(
int expected,
int actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (Object, Object)

Asserts that two objects are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(
object expected,
object actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (Single, Single, Single)

/// Asserts that two singles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(
float expected,
float actual,
float delta
);

Parameters

expected
The expected value
actual
The actual value
delta
The maximum acceptable difference between the the expected and the actual

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (String, Double, Double, Double)

Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(
string message,
double expected,
double actual,
double delta
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (String, Int32, Int32)

Asserts that two ints are equal. If they are not an AssertionException is thrown.

public static void AssertEquals(
string message,
int expected,
int actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (String, Object, Object)

Asserts that two objects are equal. Two objects are considered equal if both are null, or if both have the same value. Numeric types are compared via string comparision on their contents to avoid problems comparing values between different types. All non-numeric types are compared by using the Equals method. If they are not equal an AssertionException is thrown.

public static void AssertEquals(
string message,
object expected,
object actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


Assertion.AssertEquals Method (String, Single, Single, Single)

Asserts that two floats are equal concerning a delta. If the expected value is infinity then the delta value is ignored.

public static void AssertEquals(
string message,
float expected,
float actual,
float delta
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertEquals Overload List


AssertNotNull Method

An NDoc Documented Class Library

Assertion.AssertNotNull Method

Asserts that an object isn't null.

Overload List

Asserts that an object isn't null.

public static void AssertNotNull(object);

Asserts that an object isn't null.

public static void AssertNotNull(string,object);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.AssertNotNull Method (Object)

Asserts that an object isn't null.

public static void AssertNotNull(
object anObject
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertNotNull Overload List


Assertion.AssertNotNull Method (String, Object)

Asserts that an object isn't null.

public static void AssertNotNull(
string message,
object anObject
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertNotNull Overload List


AssertNull Method

An NDoc Documented Class Library

Assertion.AssertNull Method

Asserts that an object is null.

Overload List

Asserts that an object is null.

public static void AssertNull(object);

Asserts that an object is null.

public static void AssertNull(string,object);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.AssertNull Method (Object)

Asserts that an object is null.

public static void AssertNull(
object anObject
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertNull Overload List


Assertion.AssertNull Method (String, Object)

Asserts that an object is null.

public static void AssertNull(
string message,
object anObject
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertNull Overload List


AssertSame Method

An NDoc Documented Class Library

Assertion.AssertSame Method

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

Overload List

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AssertSame(object,object);

Asserts that two objects refer to the same object. If they are not an AssertionException is thrown.

public static void AssertSame(string,object,object);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.AssertSame Method (Object, Object)

Asserts that two objects refer to the same object. If they are not the same an AssertionException is thrown.

public static void AssertSame(
object expected,
object actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertSame Overload List


Assertion.AssertSame Method (String, Object, Object)

Asserts that two objects refer to the same object. If they are not an AssertionException is thrown.

public static void AssertSame(
string message,
object expected,
object actual
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.AssertSame Overload List


Fail Method

An NDoc Documented Class Library

Assertion.Fail Method

Fails a test with no message.

Overload List

Fails a test with no message.

public static void Fail();

Fails a test with the given message.

public static void Fail(string);

See Also

Assertion Class | NUnit.Framework Namespace


Assertion.Fail Method ()

Fails a test with no message.

public static void Fail();

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.Fail Overload List


Assertion.Fail Method (String)

Fails a test with the given message.

public static void Fail(
string message
);

See Also

Assertion Class | NUnit.Framework Namespace | Assertion.Fail Overload List


AssertionException Class

Thrown when an assertion failed.

For a list of all members of this type, see AssertionException Members.

System.Object
Exception
AssertionException

public class AssertionException : Exception

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

AssertionException Members | NUnit.Framework Namespace


AssertionException Members

AssertionException overview

Public Instance Constructors

AssertionException Overloaded. Initializes a new instance of the AssertionException class.

Public Instance Properties

HelpLink (inherited from Exception)
InnerException (inherited from Exception)
Message (inherited from Exception)
Source (inherited from Exception)
StackTrace (inherited from Exception)
TargetSite (inherited from Exception)

Public Instance Methods

Equals (inherited from Object)
GetBaseException (inherited from Exception)
GetHashCode (inherited from Object)
GetObjectData (inherited from Exception)
GetType (inherited from Object)
ToString (inherited from Exception)

Protected Instance Constructors

AssertionException Overloaded. Initializes a new instance of the AssertionException class.

Protected Instance Properties

HResult (inherited from Exception)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

AssertionException Class | NUnit.Framework Namespace


AssertionException Constructor

Overload List

Serialization Constructor

protected AssertionException(SerializationInfo,StreamingContext);

public AssertionException(string);

Standard constructor

public AssertionException(string,Exception);

See Also

AssertionException Class | NUnit.Framework Namespace


AssertionException Constructor (String)

public AssertionException(
string message
);

Parameters

message

See Also

AssertionException Class | NUnit.Framework Namespace | AssertionException Constructor Overload List


AssertionException Constructor (String, Exception)

Standard constructor

public AssertionException(
string message,
Exception inner
);

Parameters

message
The error message that explains the reason for the exception
inner
The exception that caused the current exception

See Also

AssertionException Class | NUnit.Framework Namespace | AssertionException Constructor Overload List


AssertionException Constructor (SerializationInfo, StreamingContext)

Serialization Constructor

protected AssertionException(
SerializationInfo info,
StreamingContext context
);

See Also

AssertionException Class | NUnit.Framework Namespace | AssertionException Constructor Overload List


AssertionFailureMessage Class

Summary description for AssertionFailureMessage.

For a list of all members of this type, see AssertionFailureMessage Members.

System.Object
AssertionFailureMessage

public class AssertionFailureMessage

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

AssertionFailureMessage Members | NUnit.Framework Namespace


AssertionFailureMessage Members

AssertionFailureMessage overview

Public Static Methods

FormatMessageForFailArraysNotEqual | Called to create a message when two arrays are not equal.
FormatMessageForFailNotEquals | Called to create a message when two objects have been found to be unequal. If the inputs are strings, a special message is rendered that can help track down where the strings are different, based on differences in length, or differences in content. If the inputs are not strings, the ToString method of the objects is used to show what is different about them.

Protected Static Properties

PostClipLength | Number of characters after a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."
PreClipLength | Number of characters before a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."

Protected Static Methods

AppendExpectedAndActual | Raw line that communicates the expected value, and the actual value
AppendPositionMarker | Draws a marker under the expected/actual strings that highlights where in the string a mismatch occurred.
BuildArrayLengthDifferentReport | Reports the length of two arrays that are different lengths
BuildArrayLengthReport | Reports whether the array lengths are the same or different, and what the array lengths are.
BuildArrayLengthSameReport | Reports the length of two arrays that are the same length
BuildContentDifferentMessage | Constructs a message that can be displayed when the content of two strings are different, but the string lengths are the same. The message will clip the strings to a reasonable length, centered around the first position where they are mismatched, and draw a line marking the position of the difference to make comparison quicker.
BuildLengthsDifferentMessage | Used to construct a message when the lengths of two strings are different. Also includes the strings themselves, to allow them to be compared visually.
BuildStringLengthDifferentReport | Reports the length of two strings that are different lengths
BuildStringLengthReport | Reports whether the string lengths are the same or different, and what the string lengths are.
BuildStringLengthSameReport | Reports the length of two strings that are the same length
ButWasText | Text rendered for the actual value. This text should be the same length as the Expected text, so leading spaces should pad this string to ensure they match.
ClipAroundPosition | Renders up to M characters before, and up to N characters after the specified index position. If leading or trailing text is clipped, and elipses "..." is added where the missing text would be. Clips strings to limit previous or post newline characters, since these mess up the comparison
ConvertWhitespace | Turns CR, LF, or TAB into visual indicator to preserve visual marker position. This is done by replacing the '\r' into '\\' and 'r' characters, and the '\n' into '\\' and 'n' characters, and '\t' into '\\' and 't' characters. Thus the single character becomes two characters for display.
CreateStringBuilder | Used to create a StringBuilder that is used for constructing the output message when text is different. Handles initialization when a message is provided. If message is null, an empty StringBuilder is returned.
DisplayString | Display an object as a string
ExpectedText | Text that is rendered for the expected value
InputsAreStrings | Tests two objects to determine if they are strings.
LengthsDifferent | Overloaded. Tests if two strings are different lengths.
PostClip | Clips the string after the specified position, and appends ellipses (...) to show that clipping has occurred
PreClip | Clips the string before the specified position, and appends ellipses (...) to show that clipping has occurred
Quoted | Quote a string

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Constructors

AssertionFailureMessage Constructor Protected constructor, used since this class is only used via static methods

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage Constructor

Protected constructor, used since this class is only used via static methods

protected AssertionFailureMessage();

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage Properties

The properties of the AssertionFailureMessage class are listed below. For a complete list of AssertionFailureMessage class members, see the AssertionFailureMessage Members topic.

Protected Static Properties

PostClipLength | Number of characters after a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."
PreClipLength | Number of characters before a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.PostClipLength Property

Number of characters after a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."

protected static int PostClipLength {get;}

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.PreClipLength Property

Number of characters before a highlighted position before clipping will occur. Clipped text is replaced with an elipses "..."

protected static int PreClipLength {get;}

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage Methods

The methods of the AssertionFailureMessage class are listed below. For a complete list of AssertionFailureMessage class members, see the AssertionFailureMessage Members topic.

Public Static Methods

FormatMessageForFailArraysNotEqual | Called to create a message when two arrays are not equal.
FormatMessageForFailNotEquals | Called to create a message when two objects have been found to be unequal. If the inputs are strings, a special message is rendered that can help track down where the strings are different, based on differences in length, or differences in content. If the inputs are not strings, the ToString method of the objects is used to show what is different about them.

Protected Static Methods

AppendExpectedAndActual | Raw line that communicates the expected value, and the actual value
AppendPositionMarker | Draws a marker under the expected/actual strings that highlights where in the string a mismatch occurred.
BuildArrayLengthDifferentReport | Reports the length of two arrays that are different lengths
BuildArrayLengthReport | Reports whether the array lengths are the same or different, and what the array lengths are.
BuildArrayLengthSameReport | Reports the length of two arrays that are the same length
BuildContentDifferentMessage | Constructs a message that can be displayed when the content of two strings are different, but the string lengths are the same. The message will clip the strings to a reasonable length, centered around the first position where they are mismatched, and draw a line marking the position of the difference to make comparison quicker.
BuildLengthsDifferentMessage | Used to construct a message when the lengths of two strings are different. Also includes the strings themselves, to allow them to be compared visually.
BuildStringLengthDifferentReport | Reports the length of two strings that are different lengths
BuildStringLengthReport | Reports whether the string lengths are the same or different, and what the string lengths are.
BuildStringLengthSameReport | Reports the length of two strings that are the same length
ButWasText | Text rendered for the actual value. This text should be the same length as the Expected text, so leading spaces should pad this string to ensure they match.
ClipAroundPosition | Renders up to M characters before, and up to N characters after the specified index position. If leading or trailing text is clipped, and elipses "..." is added where the missing text would be. Clips strings to limit previous or post newline characters, since these mess up the comparison
ConvertWhitespace | Turns CR, LF, or TAB into visual indicator to preserve visual marker position. This is done by replacing the '\r' into '\\' and 'r' characters, and the '\n' into '\\' and 'n' characters, and '\t' into '\\' and 't' characters. Thus the single character becomes two characters for display.
CreateStringBuilder | Used to create a StringBuilder that is used for constructing the output message when text is different. Handles initialization when a message is provided. If message is null, an empty StringBuilder is returned.
DisplayString | Display an object as a string
ExpectedText | Text that is rendered for the expected value
InputsAreStrings | Tests two objects to determine if they are strings.
LengthsDifferent | Overloaded. Tests if two strings are different lengths.
PostClip | Clips the string after the specified position, and appends ellipses (...) to show that clipping has occurred
PreClip | Clips the string before the specified position, and appends ellipses (...) to show that clipping has occurred
Quoted | Quote a string

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.AppendExpectedAndActual Method

Raw line that communicates the expected value, and the actual value

protected static void AppendExpectedAndActual(
StringBuilder sbOutput,
object expected,
object actual
);

Parameters

sbOutput
expected
actual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.AppendPositionMarker Method

Draws a marker under the expected/actual strings that highlights where in the string a mismatch occurred.

protected static void AppendPositionMarker(
StringBuilder sbOutput,
int iPosition
);

Parameters

sbOutput
iPosition

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildArrayLengthDifferentReport Method

Reports the length of two arrays that are different lengths

protected static void BuildArrayLengthDifferentReport(
StringBuilder sbOutput,
Array expected,
Array actual
);

Parameters

sbOutput
expected
actual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildArrayLengthReport Method

Reports whether the array lengths are the same or different, and what the array lengths are.

protected static void BuildArrayLengthReport(
StringBuilder sbOutput,
Array expected,
Array actual
);

Parameters

sbOutput
expected
actual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildArrayLengthSameReport Method

Reports the length of two arrays that are the same length

protected static void BuildArrayLengthSameReport(
StringBuilder sbOutput,
Array expected,
Array actual
);

Parameters

sbOutput
expected
actual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildContentDifferentMessage Method

Constructs a message that can be displayed when the content of two strings are different, but the string lengths are the same. The message will clip the strings to a reasonable length, centered around the first position where they are mismatched, and draw a line marking the position of the difference to make comparison quicker.

protected static void BuildContentDifferentMessage(
StringBuilder sbOutput,
string sExpected,
string sActual
);

Parameters

sbOutput
sExpected
sActual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildLengthsDifferentMessage Method

Used to construct a message when the lengths of two strings are different. Also includes the strings themselves, to allow them to be compared visually.

protected static void BuildLengthsDifferentMessage(
StringBuilder sbOutput,
string sExpected,
string sActual
);

Parameters

sbOutput
sExpected
sActual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildStringLengthDifferentReport Method

Reports the length of two strings that are different lengths

protected static void BuildStringLengthDifferentReport(
StringBuilder sbOutput,
string sExpected,
string sActual
);

Parameters

sbOutput
sExpected
sActual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildStringLengthReport Method

Reports whether the string lengths are the same or different, and what the string lengths are.

protected static void BuildStringLengthReport(
StringBuilder sbOutput,
string sExpected,
string sActual
);

Parameters

sbOutput
sExpected
sActual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.BuildStringLengthSameReport Method

Reports the length of two strings that are the same length

protected static void BuildStringLengthSameReport(
StringBuilder sbOutput,
string sExpected,
string sActual
);

Parameters

sbOutput
sExpected
sActual

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.ButWasText Method

Text rendered for the actual value. This text should be the same length as the Expected text, so leading spaces should pad this string to ensure they match.

protected static string ButWasText();

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.ClipAroundPosition Method

Renders up to M characters before, and up to N characters after the specified index position. If leading or trailing text is clipped, and elipses "..." is added where the missing text would be. Clips strings to limit previous or post newline characters, since these mess up the comparison

protected static string ClipAroundPosition(
string sString,
int iPosition
);

Parameters

sString
iPosition

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.ConvertWhitespace Method

Turns CR, LF, or TAB into visual indicator to preserve visual marker position. This is done by replacing the '\r' into '\\' and 'r' characters, and the '\n' into '\\' and 'n' characters, and '\t' into '\\' and 't' characters. Thus the single character becomes two characters for display.

protected static string ConvertWhitespace(
string sInput
);

Parameters

sInput

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.CreateStringBuilder Method

Used to create a StringBuilder that is used for constructing the output message when text is different. Handles initialization when a message is provided. If message is null, an empty StringBuilder is returned.

protected static StringBuilder CreateStringBuilder(
string message,
params object[] args
);

Parameters

message
args

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.DisplayString Method

Display an object as a string

protected static string DisplayString(
object obj
);

Parameters

obj

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.ExpectedText Method

Text that is rendered for the expected value

protected static string ExpectedText();

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.FormatMessageForFailArraysNotEqual Method

Called to create a message when two arrays are not equal.

public static string FormatMessageForFailArraysNotEqual(
int index,
Array expected,
Array actual,
string message,
params object[] args
);

Parameters

index
expected
actual
message
args

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.FormatMessageForFailNotEquals Method

Called to create a message when two objects have been found to be unequal. If the inputs are strings, a special message is rendered that can help track down where the strings are different, based on differences in length, or differences in content. If the inputs are not strings, the ToString method of the objects is used to show what is different about them.

public static string FormatMessageForFailNotEquals(
object expected,
object actual,
string message,
params object[] args
);

Parameters

expected
actual
message
args

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.InputsAreStrings Method

Tests two objects to determine if they are strings.

protected static bool InputsAreStrings(
object expected,
object actual
);

Parameters

expected
actual

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


LengthsDifferent Method

An NDoc Documented Class Library

AssertionFailureMessage.LengthsDifferent Method

Tests if two arrays are different lengths.

Overload List

Tests if two arrays are different lengths.

protected static bool LengthsDifferent(object[],object[]);

Tests if two strings are different lengths.

protected static bool LengthsDifferent(string,string);

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.LengthsDifferent Method (Object[], Object[])

Tests if two arrays are different lengths.

protected static bool LengthsDifferent(
object[] expected,
object[] actual
);

Parameters

expected
actual

Return Value

True if array lengths are different

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace | AssertionFailureMessage.LengthsDifferent Overload List


AssertionFailureMessage.LengthsDifferent Method (String, String)

Tests if two strings are different lengths.

protected static bool LengthsDifferent(
string sExpected,
string sActual
);

Parameters

sExpected
sActual

Return Value

True if string lengths are different

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace | AssertionFailureMessage.LengthsDifferent Overload List


AssertionFailureMessage.PostClip Method

Clips the string after the specified position, and appends ellipses (...) to show that clipping has occurred

protected static string PostClip(
string sString,
int iPosition
);

Parameters

sString
iPosition

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.PreClip Method

Clips the string before the specified position, and appends ellipses (...) to show that clipping has occurred

protected static string PreClip(
string sString,
int iPosition
);

Parameters

sString
iPosition

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


AssertionFailureMessage.Quoted Method

Quote a string

protected static string Quoted(
string text
);

Parameters

text

Return Value

See Also

AssertionFailureMessage Class | NUnit.Framework Namespace


CategoryAttribute Class

Summary description for CategoryAttribute.

For a list of all members of this type, see CategoryAttribute Members.

System.Object
Attribute
CategoryAttribute

public sealed class CategoryAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

CategoryAttribute Members | NUnit.Framework Namespace


CategoryAttribute Members

CategoryAttribute overview

Public Instance Constructors

CategoryAttribute Constructor Construct attribute for a given category

Public Instance Properties

Name | The name of the category
TypeId (inherited from Attribute) |

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

CategoryAttribute Class | NUnit.Framework Namespace


CategoryAttribute Constructor

Construct attribute for a given category

public CategoryAttribute(
string name
);

Parameters

name
The name of the category

See Also

CategoryAttribute Class | NUnit.Framework Namespace


CategoryAttribute Properties

The properties of the CategoryAttribute class are listed below. For a complete list of CategoryAttribute class members, see the CategoryAttribute Members topic.

Public Instance Properties

Name | The name of the category
TypeId (inherited from Attribute) |

See Also

CategoryAttribute Class | NUnit.Framework Namespace


CategoryAttribute.Name Property

The name of the category

public string Name {get;}

See Also

CategoryAttribute Class | NUnit.Framework Namespace


ExpectedExceptionAttribute Class

ExpectedAttributeException.

For a list of all members of this type, see ExpectedExceptionAttribute Members.

System.Object
Attribute
ExpectedExceptionAttribute

public sealed class ExpectedExceptionAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

ExpectedExceptionAttribute Members | NUnit.Framework Namespace


ExpectedExceptionAttribute Members

ExpectedExceptionAttribute overview

Public Instance Constructors

ExpectedExceptionAttribute Overloaded. Initializes a new instance of the ExpectedExceptionAttribute class.

Public Instance Properties

ExceptionType | The expected exception type
ExpectedMessage | The expected message
TypeId (inherited from Attribute) |

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace


ExpectedExceptionAttribute Constructor

Constructor for a given type of exception

Overload List

Constructor for a given type of exception

public ExpectedExceptionAttribute(Type);

Constructor for a given type of exception and expected message text

public ExpectedExceptionAttribute(Type,string);

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace


ExpectedExceptionAttribute Constructor (Type)

Constructor for a given type of exception

public ExpectedExceptionAttribute(
Type exceptionType
);

Parameters

exceptionType

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace | ExpectedExceptionAttribute Constructor Overload List


ExpectedExceptionAttribute Constructor (Type, String)

Constructor for a given type of exception and expected message text

public ExpectedExceptionAttribute(
Type exceptionType,
string expectedMessage
);

Parameters

exceptionType
expectedMessage

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace | ExpectedExceptionAttribute Constructor Overload List


ExpectedExceptionAttribute Properties

The properties of the ExpectedExceptionAttribute class are listed below. For a complete list of ExpectedExceptionAttribute class members, see the ExpectedExceptionAttribute Members topic.

Public Instance Properties

ExceptionType | The expected exception type
ExpectedMessage | The expected message
TypeId (inherited from Attribute) |

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace


ExpectedExceptionAttribute.ExceptionType Property

The expected exception type

public System.Type ExceptionType {get; set;}

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace


ExpectedExceptionAttribute.ExpectedMessage Property

The expected message

public string ExpectedMessage {get; set;}

See Also

ExpectedExceptionAttribute Class | NUnit.Framework Namespace


ExplicitAttribute Class

ExplicitAttribute marks a test or test fixture so that it will only be run if explicitly executed from the gui or command line or if it is included by use of a filter. The test will not be run simply because an enclosing suite is run.

For a list of all members of this type, see ExplicitAttribute Members.

System.Object
Attribute
ExplicitAttribute

public sealed class ExplicitAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

ExplicitAttribute Members | NUnit.Framework Namespace


ExplicitAttribute Members

ExplicitAttribute overview

Public Instance Constructors

ExplicitAttribute Constructor Constructor

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

ExplicitAttribute Class | NUnit.Framework Namespace


ExplicitAttribute Constructor

Constructor

public ExplicitAttribute();

See Also

ExplicitAttribute Class | NUnit.Framework Namespace


IgnoreAttribute Class

IgnoreAttribute.

For a list of all members of this type, see IgnoreAttribute Members.

System.Object
Attribute
IgnoreAttribute

public sealed class IgnoreAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

IgnoreAttribute Members | NUnit.Framework Namespace


IgnoreAttribute Members

IgnoreAttribute overview

Public Instance Constructors

IgnoreAttribute Constructor Constructor

Public Instance Properties

Reason | The reason for ignoring a test
TypeId (inherited from Attribute) |

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

IgnoreAttribute Class | NUnit.Framework Namespace


IgnoreAttribute Constructor

Constructor

public IgnoreAttribute(
string reason
);

Parameters

reason

See Also

IgnoreAttribute Class | NUnit.Framework Namespace


IgnoreAttribute Properties

The properties of the IgnoreAttribute class are listed below. For a complete list of IgnoreAttribute class members, see the IgnoreAttribute Members topic.

Public Instance Properties

Reason | The reason for ignoring a test
TypeId (inherited from Attribute) |

See Also

IgnoreAttribute Class | NUnit.Framework Namespace


IgnoreAttribute.Reason Property

The reason for ignoring a test

public string Reason {get;}

See Also

IgnoreAttribute Class | NUnit.Framework Namespace


IgnoreException Class

Thrown when an assertion failed.

For a list of all members of this type, see IgnoreException Members.

System.Object
Exception
IgnoreException

public class IgnoreException : Exception

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

IgnoreException Members | NUnit.Framework Namespace


IgnoreException Members

IgnoreException overview

Public Instance Constructors

IgnoreException Overloaded. Initializes a new instance of the IgnoreException class.

Public Instance Properties

HelpLink (inherited from Exception)
InnerException (inherited from Exception)
Message (inherited from Exception)
Source (inherited from Exception)
StackTrace (inherited from Exception)
TargetSite (inherited from Exception)

Public Instance Methods

Equals (inherited from Object)
GetBaseException (inherited from Exception)
GetHashCode (inherited from Object)
GetObjectData (inherited from Exception)
GetType (inherited from Object)
ToString (inherited from Exception)

Protected Instance Constructors

IgnoreException Overloaded. Initializes a new instance of the IgnoreException class.

Protected Instance Properties

HResult (inherited from Exception)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

IgnoreException Class | NUnit.Framework Namespace


IgnoreException Constructor

Overload List

Serialization Constructor

protected IgnoreException(SerializationInfo,StreamingContext);

public IgnoreException(string);

Standard constructor

public IgnoreException(string,Exception);

See Also

IgnoreException Class | NUnit.Framework Namespace


IgnoreException Constructor (String)

public IgnoreException(
string message
);

Parameters

message

See Also

IgnoreException Class | NUnit.Framework Namespace | IgnoreException Constructor Overload List


IgnoreException Constructor (String, Exception)

Standard constructor

public IgnoreException(
string message,
Exception inner
);

Parameters

message
The error message that explains the reason for the exception
inner
The exception that caused the current exception

See Also

IgnoreException Class | NUnit.Framework Namespace | IgnoreException Constructor Overload List


IgnoreException Constructor (SerializationInfo, StreamingContext)

Serialization Constructor

protected IgnoreException(
SerializationInfo info,
StreamingContext context
);

See Also

IgnoreException Class | NUnit.Framework Namespace | IgnoreException Constructor Overload List


SetUpAttribute Class

SetUpAttribute.

For a list of all members of this type, see SetUpAttribute Members.

System.Object
Attribute
SetUpAttribute

public sealed class SetUpAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

SetUpAttribute Members | NUnit.Framework Namespace


SetUpAttribute Members

SetUpAttribute overview

Public Instance Constructors

SetUpAttribute Constructor Initializes a new instance of the SetUpAttribute class.

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

SetUpAttribute Class | NUnit.Framework Namespace


SetUpAttribute Constructor

Initializes a new instance of the SetUpAttribute class.

public SetUpAttribute();

See Also

SetUpAttribute Class | NUnit.Framework Namespace


SuiteAttribute Class

SuiteAttribute.

For a list of all members of this type, see SuiteAttribute Members.

System.Object
Attribute
SuiteAttribute

public sealed class SuiteAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

SuiteAttribute Members | NUnit.Framework Namespace


SuiteAttribute Members

SuiteAttribute overview

Public Instance Constructors

SuiteAttribute Constructor Initializes a new instance of the SuiteAttribute class.

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

SuiteAttribute Class | NUnit.Framework Namespace


SuiteAttribute Constructor

Initializes a new instance of the SuiteAttribute class.

public SuiteAttribute();

See Also

SuiteAttribute Class | NUnit.Framework Namespace


TearDownAttribute Class

TearDownAttribute.

For a list of all members of this type, see TearDownAttribute Members.

System.Object
Attribute
TearDownAttribute

public sealed class TearDownAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TearDownAttribute Members | NUnit.Framework Namespace


TearDownAttribute Members

TearDownAttribute overview

Public Instance Constructors

TearDownAttribute Constructor Initializes a new instance of the TearDownAttribute class.

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

TearDownAttribute Class | NUnit.Framework Namespace


TearDownAttribute Constructor

Initializes a new instance of the TearDownAttribute class.

public TearDownAttribute();

See Also

TearDownAttribute Class | NUnit.Framework Namespace


TestAttribute Class

Adding this attribute to a method within a class makes the method callable from the NUnit test runner. There is a property called Description which is optional which you can provide a more detailed test description. This class cannot be inherited.

For a list of all members of this type, see TestAttribute Members.

System.Object
Attribute
TestAttribute

public sealed class TestAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

[TestFixture] public class Fixture { [Test] public void MethodToTest() {} [Test(Description = "more detailed description")] publc void TestDescriptionMethod() {} }

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TestAttribute Members | NUnit.Framework Namespace | TestFixtureAttribute


TestAttribute Members

TestAttribute overview

Public Instance Constructors

TestAttribute Constructor Initializes a new instance of the TestAttribute class.

Public Instance Properties

Description | Descriptive text for this test
TypeId (inherited from Attribute) |

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

TestAttribute Class | NUnit.Framework Namespace | TestFixtureAttribute


TestAttribute Constructor

Initializes a new instance of the TestAttribute class.

public TestAttribute();

See Also

TestAttribute Class | NUnit.Framework Namespace


TestAttribute Properties

The properties of the TestAttribute class are listed below. For a complete list of TestAttribute class members, see the TestAttribute Members topic.

Public Instance Properties

Description | Descriptive text for this test
TypeId (inherited from Attribute) |

See Also

TestAttribute Class | NUnit.Framework Namespace | TestFixtureAttribute


TestAttribute.Description Property

Descriptive text for this test

public string Description {get; set;}

See Also

TestAttribute Class | NUnit.Framework Namespace


TestCase Class

NOTE: This class is now obsolete.

use TestFixture attribute instead of inheritance

TestFixture

For a list of all members of this type, see TestCase Members.

System.Object
Assertion
TestCase

public class TestCase : Assertion

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TestCase Members | NUnit.Framework Namespace


TestCase Members

TestCase overview

Public Instance Constructors

TestCase Constructor Initializes a new instance of the TestCase class.

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object) |
MemberwiseClone (inherited from Object) |
SetUp | Obsolete. SetUp method
TearDown | Obsolete. TearDown method

See Also

TestCase Class | NUnit.Framework Namespace


TestCase Constructor

Initializes a new instance of the TestCase class.

public TestCase();

See Also

TestCase Class | NUnit.Framework Namespace


TestCase Methods

The methods of the TestCase class are listed below. For a complete list of TestCase class members, see the TestCase Members topic.

Public Instance Methods

Equals (inherited from Object)
GetHashCode (inherited from Object)
GetType (inherited from Object)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object) |
MemberwiseClone (inherited from Object) |
SetUp | Obsolete. SetUp method
TearDown | Obsolete. TearDown method

See Also

TestCase Class | NUnit.Framework Namespace


TestCase.SetUp Method

NOTE: This method is now obsolete.

use SetUp attribute instead of naming convention

SetUp method

protected virtual void SetUp();

See Also

TestCase Class | NUnit.Framework Namespace


TestCase.TearDown Method

NOTE: This method is now obsolete.

use TearDown attribute instead of naming convention

TearDown method

protected virtual void TearDown();

See Also

TestCase Class | NUnit.Framework Namespace


TestFixtureAttribute Class

TestFixtureAttribute

For a list of all members of this type, see TestFixtureAttribute Members.

System.Object
Attribute
TestFixtureAttribute

public sealed class TestFixtureAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

[TestFixture] public class ExampleClass {}

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TestFixtureAttribute Members | NUnit.Framework Namespace


TestFixtureAttribute Members

TestFixtureAttribute overview

Public Instance Constructors

TestFixtureAttribute Constructor Initializes a new instance of the TestFixtureAttribute class.

Public Instance Properties

Description | Descriptive text for this fixture
TypeId (inherited from Attribute) |

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

See Also

TestFixtureAttribute Class | NUnit.Framework Namespace


TestFixtureAttribute Constructor

Initializes a new instance of the TestFixtureAttribute class.

public TestFixtureAttribute();

See Also

TestFixtureAttribute Class | NUnit.Framework Namespace


TestFixtureAttribute Properties

The properties of the TestFixtureAttribute class are listed below. For a complete list of TestFixtureAttribute class members, see the TestFixtureAttribute Members topic.

Public Instance Properties

Description | Descriptive text for this fixture
TypeId (inherited from Attribute) |

See Also

TestFixtureAttribute Class | NUnit.Framework Namespace


TestFixtureAttribute.Description Property

Descriptive text for this fixture

public string Description {get; set;}

See Also

TestFixtureAttribute Class | NUnit.Framework Namespace


TestFixtureSetUpAttribute Class

TestFixtureSetUpAttribute

For a list of all members of this type, see TestFixtureSetUpAttribute Members.

System.Object
Attribute
TestFixtureSetUpAttribute

public class TestFixtureSetUpAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TestFixtureSetUpAttribute Members | NUnit.Framework Namespace


TestFixtureSetUpAttribute Members

TestFixtureSetUpAttribute overview

Public Instance Constructors

TestFixtureSetUpAttribute Constructor Initializes a new instance of the TestFixtureSetUpAttribute class.

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

TestFixtureSetUpAttribute Class | NUnit.Framework Namespace


TestFixtureSetUpAttribute Constructor

Initializes a new instance of the TestFixtureSetUpAttribute class.

public TestFixtureSetUpAttribute();

See Also

TestFixtureSetUpAttribute Class | NUnit.Framework Namespace


TestFixtureTearDownAttribute Class

TestFixtureTearDownAttribute

For a list of all members of this type, see TestFixtureTearDownAttribute Members.

System.Object
Attribute
TestFixtureTearDownAttribute

public class TestFixtureTearDownAttribute : Attribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: NUnit.Framework

Assembly: nunit.framework (in nunit.framework.dll)

See Also

TestFixtureTearDownAttribute Members | NUnit.Framework Namespace


TestFixtureTearDownAttribute Members

TestFixtureTearDownAttribute overview

Public Instance Constructors

TestFixtureTearDownAttribute Constructor Initializes a new instance of the TestFixtureTearDownAttribute class.

Public Instance Properties

TypeId (inherited from Attribute)

Public Instance Methods

Equals (inherited from Attribute)
GetHashCode (inherited from Attribute)
GetType (inherited from Object)
IsDefaultAttribute (inherited from Attribute)
Match (inherited from Attribute)
ToString (inherited from Object)

Protected Instance Methods

Finalize (inherited from Object)
MemberwiseClone (inherited from Object)

See Also

TestFixtureTearDownAttribute Class | NUnit.Framework Namespace


TestFixtureTearDownAttribute Constructor

Initializes a new instance of the TestFixtureTearDownAttribute class.

public TestFixtureTearDownAttribute();

See Also

TestFixtureTearDownAttribute Class | NUnit.Framework Namespace