Assert 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
AssertAssert

Constructors

Assert() 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(Double, Nullable<Double>, Double, String, Object[]) AreEqual(Double, Nullable<Double>, Double, String, Object[])
AreEqual(Double, Double, Double, String, Object[]) AreEqual(Double, Double, Double, String, Object[])
AreEqual(UInt64, UInt64, String, Object[]) AreEqual(UInt64, UInt64, String, Object[])
AreEqual(UInt32, UInt32, String, Object[]) AreEqual(UInt32, UInt32, String, Object[])
AreEqual(Object, Object, String, Object[]) AreEqual(Object, Object, String, Object[])
AreEqual(Int64, Int64, String, Object[]) AreEqual(Int64, Int64, String, Object[])
AreEqual(Double, Nullable<Double>, Double, String) AreEqual(Double, Nullable<Double>, Double, String)
AreEqual(Double, Double, Double, String) AreEqual(Double, Double, Double, String)
AreEqual(Decimal, Decimal, String, Object[]) AreEqual(Decimal, Decimal, String, Object[])
AreEqual(UInt64, UInt64, String) AreEqual(UInt64, UInt64, String)
AreEqual(UInt32, UInt32, String) AreEqual(UInt32, UInt32, String)
AreEqual(Int32, Int32, String, Object[]) AreEqual(Int32, Int32, String, Object[])
AreEqual(Int64, Int64, String) AreEqual(Int64, Int64, String)
AreEqual(Object, Object, String) AreEqual(Object, Object, String)
AreEqual(Int32, Int32) AreEqual(Int32, Int32)
AreEqual(Int64, Int64) AreEqual(Int64, Int64)
AreEqual(Object, Object) AreEqual(Object, Object)
AreEqual(UInt32, UInt32) AreEqual(UInt32, UInt32)
AreEqual(Decimal, Decimal) AreEqual(Decimal, Decimal)
AreEqual(Decimal, Decimal, String) AreEqual(Decimal, Decimal, String)
AreEqual(Double, Double, Double) AreEqual(Double, Double, Double)
AreEqual(Double, Nullable<Double>, Double) AreEqual(Double, Nullable<Double>, Double)
AreEqual(Int32, Int32, String) AreEqual(Int32, Int32, String)
AreEqual(UInt64, UInt64) AreEqual(UInt64, UInt64)
AreNotEqual(Single, Single, String) AreNotEqual(Single, Single, String)
AreNotEqual(UInt32, UInt32, String) AreNotEqual(UInt32, UInt32, String)
AreNotEqual(UInt64, UInt64, String) AreNotEqual(UInt64, UInt64, String)
AreNotEqual(Decimal, Decimal, String, Object[]) AreNotEqual(Decimal, Decimal, String, Object[])
AreNotEqual(Double, Double, String, Object[]) AreNotEqual(Double, Double, String, Object[])
AreNotEqual(Object, Object, String, Object[]) AreNotEqual(Object, Object, String, Object[])
AreNotEqual(Int64, Int64, String, Object[]) AreNotEqual(Int64, Int64, String, Object[])
AreNotEqual(Single, Single, String, Object[]) AreNotEqual(Single, Single, String, Object[])
AreNotEqual(UInt32, UInt32, String, Object[]) AreNotEqual(UInt32, UInt32, String, Object[])
AreNotEqual(UInt64, UInt64, String, Object[]) AreNotEqual(UInt64, UInt64, String, Object[])
AreNotEqual(Int32, Int32, String, Object[]) AreNotEqual(Int32, Int32, String, Object[])
AreNotEqual(Object, Object, String) AreNotEqual(Object, Object, String)
AreNotEqual(UInt64, UInt64) AreNotEqual(UInt64, UInt64)
AreNotEqual(Int32, Int32, String) AreNotEqual(Int32, Int32, String)
AreNotEqual(Double, Double, String) AreNotEqual(Double, Double, String)
AreNotEqual(Decimal, Decimal, String) AreNotEqual(Decimal, Decimal, String)
AreNotEqual(Int64, Int64, String) AreNotEqual(Int64, Int64, String)
AreNotEqual(UInt32, UInt32) AreNotEqual(UInt32, UInt32)
AreNotEqual(Single, Single) AreNotEqual(Single, Single)
AreNotEqual(Object, Object) AreNotEqual(Object, Object)
AreNotEqual(Int64, Int64) AreNotEqual(Int64, Int64)
AreNotEqual(Int32, Int32) AreNotEqual(Int32, Int32)
AreNotEqual(Double, Double) AreNotEqual(Double, Double)
AreNotEqual(Decimal, Decimal) AreNotEqual(Decimal, Decimal)
AreNotSame(Object, Object, String) AreNotSame(Object, Object, String)
AreNotSame(Object, Object, String, Object[]) AreNotSame(Object, Object, String, Object[])
AreNotSame(Object, Object) AreNotSame(Object, Object)
AreSame(Object, Object) AreSame(Object, Object)
AreSame(Object, Object, String) AreSame(Object, Object, String)
AreSame(Object, Object, String, Object[]) AreSame(Object, Object, String, Object[])
AssertDoublesAreEqual(Double, Double, Double, String, Object[]) AssertDoublesAreEqual(Double, Double, Double, String, Object[])
ByVal(Object, IResolveConstraint) ByVal(Object, IResolveConstraint)
ByVal(Object, IResolveConstraint, String) ByVal(Object, IResolveConstraint, String)
ByVal(Object, IResolveConstraint, String, Object[]) ByVal(Object, IResolveConstraint, String, Object[])
Catch(Type, TestDelegate, String, Object[]) Catch(Type, TestDelegate, String, Object[])
Catch(TestDelegate) Catch(TestDelegate)
Catch(TestDelegate, String) Catch(TestDelegate, String)
Catch(Type, TestDelegate) Catch(Type, TestDelegate)
Catch(TestDelegate, String, Object[]) Catch(TestDelegate, String, Object[])
Catch(Type, TestDelegate, String) Catch(Type, TestDelegate, String)
Catch<T>(TestDelegate, String) Catch<T>(TestDelegate, String)
Catch<T>(TestDelegate, String, Object[]) Catch<T>(TestDelegate, String, Object[])
Catch<T>(TestDelegate) Catch<T>(TestDelegate)
DoesNotThrow(TestDelegate) DoesNotThrow(TestDelegate)
DoesNotThrow(TestDelegate, String) DoesNotThrow(TestDelegate, String)
DoesNotThrow(TestDelegate, String, Object[]) DoesNotThrow(TestDelegate, String, Object[])
Equals(Object, 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()
Fail(String) Fail(String)
Fail(String, Object[]) Fail(String, Object[])

Throw an assertion exception with a message and optional arguments

False(Boolean) False(Boolean)

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

False(Boolean, String) False(Boolean, String)

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

False(Boolean, String, Object[]) False(Boolean, String, Object[])

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

Ignore() Ignore()

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

Ignore(String) Ignore(String)

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

Ignore(String, Object[]) 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(String) Inconclusive(String)

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

Inconclusive(String, Object[]) Inconclusive(String, Object[])

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

Inconclusive() Inconclusive()

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

IsFalse(Boolean) IsFalse(Boolean)
IsFalse(Boolean, String) IsFalse(Boolean, String)
IsFalse(Boolean, String, Object[]) IsFalse(Boolean, String, Object[])
IsInstanceOfType(Type, Object) IsInstanceOfType(Type, Object)
IsInstanceOfType(Object, String, Object[]) IsInstanceOfType(Object, String, Object[])
IsInstanceOfType(Type, Object, String) IsInstanceOfType(Type, Object, String)
IsInstanceOfType(Type, Object, String, Object[]) IsInstanceOfType(Type, Object, String, Object[])
IsNotNull(Object) IsNotNull(Object)
IsNotNull(Object, String) IsNotNull(Object, String)
IsNotNull(Object, String, Object[]) IsNotNull(Object, String, Object[])
IsNull(Object) IsNull(Object)
IsNull(Object, String) IsNull(Object, String)
IsNull(Object, String, Object[]) IsNull(Object, String, Object[])
IsTrue(Boolean, String) IsTrue(Boolean, String)
IsTrue(Boolean, String, Object[]) IsTrue(Boolean, String, Object[])
IsTrue(Boolean) IsTrue(Boolean)
NotNull(Object, String, Object[]) 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.

NotNull(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) 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.

Null(Object) 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) 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[]) 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() 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) 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[]) 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) 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(Object, IResolveConstraint, String, Object[]) 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(Boolean, String, Object[]) That(Boolean, String, Object[])

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

That(Object, IResolveConstraint) 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) 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(TestDelegate, IResolveConstraint) That(TestDelegate, IResolveConstraint)
That(Boolean) That(Boolean)

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

That(Boolean, String) That(Boolean, String)

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

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

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

True(Boolean) True(Boolean)

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

True(Boolean, String, Object[]) True(Boolean, String, Object[])

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

Applies to