Assert Class

Definition

The Assert class contains a collection of static methods that implement the most common assertions used in NUnit.

public class Assert
type Assert = class
Inheritance
Assert

Constructors

Assert()

We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object.

Methods

AreEqual(Decimal, Decimal)
AreEqual(Decimal, Decimal, String)
AreEqual(Decimal, Decimal, String, Object[])
AreEqual(Double, Double, Double)
AreEqual(Double, Double, Double, String)
AreEqual(Double, Double, Double, String, Object[])
AreEqual(Double, Nullable<Double>, Double)
AreEqual(Double, Nullable<Double>, Double, String)
AreEqual(Double, Nullable<Double>, Double, String, Object[])
AreEqual(Int32, Int32)
AreEqual(Int32, Int32, String)
AreEqual(Int32, Int32, String, Object[])
AreEqual(Int64, Int64)
AreEqual(Int64, Int64, String)
AreEqual(Int64, Int64, String, Object[])
AreEqual(Object, Object)
AreEqual(Object, Object, String)
AreEqual(Object, Object, String, Object[])
AreEqual(UInt32, UInt32)
AreEqual(UInt32, UInt32, String)
AreEqual(UInt32, UInt32, String, Object[])
AreEqual(UInt64, UInt64)
AreEqual(UInt64, UInt64, String)
AreEqual(UInt64, UInt64, String, Object[])
AreNotEqual(Decimal, Decimal)
AreNotEqual(Decimal, Decimal, String)
AreNotEqual(Decimal, Decimal, String, Object[])
AreNotEqual(Double, Double)
AreNotEqual(Double, Double, String)
AreNotEqual(Double, Double, String, Object[])
AreNotEqual(Int32, Int32)
AreNotEqual(Int32, Int32, String)
AreNotEqual(Int32, Int32, String, Object[])
AreNotEqual(Int64, Int64)
AreNotEqual(Int64, Int64, String)
AreNotEqual(Int64, Int64, String, Object[])
AreNotEqual(Object, Object)
AreNotEqual(Object, Object, String)
AreNotEqual(Object, Object, String, Object[])
AreNotEqual(Single, Single)
AreNotEqual(Single, Single, String)
AreNotEqual(Single, Single, String, Object[])
AreNotEqual(UInt32, UInt32)
AreNotEqual(UInt32, UInt32, String)
AreNotEqual(UInt32, UInt32, String, Object[])
AreNotEqual(UInt64, UInt64)
AreNotEqual(UInt64, UInt64, String)
AreNotEqual(UInt64, UInt64, String, Object[])
AreNotSame(Object, Object)
AreNotSame(Object, Object, String)
AreNotSame(Object, Object, String, Object[])
AreSame(Object, Object)
AreSame(Object, Object, String)
AreSame(Object, Object, String, Object[])
AssertDoublesAreEqual(Double, Double, Double, String, Object[])
ByVal(Object, IResolveConstraint)
ByVal(Object, IResolveConstraint, String)
ByVal(Object, IResolveConstraint, String, Object[])
Catch(TestDelegate)
Catch(TestDelegate, String)
Catch(TestDelegate, String, Object[])
Catch(Type, TestDelegate)
Catch(Type, TestDelegate, String)
Catch(Type, TestDelegate, String, Object[])
Catch<T>(TestDelegate)
Catch<T>(TestDelegate, String)
Catch<T>(TestDelegate, String, Object[])
DoesNotThrow(TestDelegate)
DoesNotThrow(TestDelegate, String)
DoesNotThrow(TestDelegate, String, Object[])
Equals(Object, Object)

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

Fail()
Fail(String)
Fail(String, Object[])

Throw an assertion exception with a message and optional arguments

False(Boolean)

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

False(Boolean, String)

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

False(Boolean, String, Object[])

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

Ignore()

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

Ignore(String)

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

Ignore(String, Object[])

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

Inconclusive()

Throws an InconclusiveException. This causes the test to be reported as Inconclusive.

Inconclusive(String)

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

Inconclusive(String, Object[])

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

IsFalse(Boolean)
IsFalse(Boolean, String)
IsFalse(Boolean, String, Object[])
IsInstanceOfType(Object, String, Object[])
IsInstanceOfType(Type, Object)
IsInstanceOfType(Type, Object, String)
IsInstanceOfType(Type, Object, String, Object[])
IsNotNull(Object)
IsNotNull(Object, String)
IsNotNull(Object, String, Object[])
IsNull(Object)
IsNull(Object, String)
IsNull(Object, String, Object[])
IsTrue(Boolean)
IsTrue(Boolean, String)
IsTrue(Boolean, String, Object[])
NotNull(Object)

Verifies that the object that is passed in is not equal to null If the object is null then an AssertionException is thrown.

NotNull(Object, String)

Verifies that the object that is passed in is not equal to null If the object is null then an AssertionException is thrown.

NotNull(Object, String, Object[])

Verifies that the object that is passed in is not equal to null If the object is null then an AssertionException is thrown.

Null(Object)

Verifies that the object that is passed in is equal to null If the object is not null null then an AssertionException is thrown.

Null(Object, String)

Verifies that the object that is passed in is equal to null If the object is not null then an AssertionException is thrown.

Null(Object, String, Object[])

Verifies that the object that is passed in is equal to null If the object is not null then an AssertionException is thrown.

Pass()

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.

Pass(String)

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.

Pass(String, Object[])

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.

ReferenceEquals(Object, Object)

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

That(Boolean)

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

That(Boolean, String)

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

That(Boolean, String, Object[])

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

That(Object, IResolveConstraint)

Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure.

That(Object, IResolveConstraint, String)

Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure.

That(Object, IResolveConstraint, String, Object[])

Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure.

That(TestDelegate, IResolveConstraint)
That<T>(ActualValueDelegate<T>, IResolveConstraint)
That<T>(ActualValueDelegate<T>, IResolveConstraint, String)
That<T>(ActualValueDelegate<T>, IResolveConstraint, String, Object[])
That<T>(T, IResolveConstraint)
That<T>(T, IResolveConstraint, String)
That<T>(T, IResolveConstraint, String, Object[])
Throws(IResolveConstraint, TestDelegate)
Throws(IResolveConstraint, TestDelegate, String)
Throws(IResolveConstraint, TestDelegate, String, Object[])
Throws(Type, TestDelegate)
Throws(Type, TestDelegate, String)
Throws(Type, TestDelegate, String, Object[])
Throws<T>(TestDelegate)
Throws<T>(TestDelegate, String)
Throws<T>(TestDelegate, String, Object[])
True(Boolean)

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

True(Boolean, String)

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

True(Boolean, String, Object[])

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

Applies to