Assert
The Assert class contains a collection of static methods that
implement the most common assertions used in NUnit.
Gets the number of assertions executed so far and
resets the counter to zero.
protected 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.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
Verifies that two values are equal. If they are not, then an
AssertionException is thrown.
public static void AreEqual(double expected, double actual, double delta, string message, object[] args)
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 equal then an AssertionException is
thrown.
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 equal then an AssertionException is
thrown.
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 equal then an AssertionException is
thrown.
public static void AreEqual(double expected, double? actual, double delta, string message, object[] args)
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 equal then an AssertionException is
thrown.
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 equal then an AssertionException is
thrown.
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 equal then an AssertionException is
thrown.
Verifies that two objects are equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are not equal an AssertionException is thrown.
Verifies that two objects are equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are not equal an AssertionException is thrown.
Verifies that two objects are equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are not equal an AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two values are not equal. If they are equal, then an
AssertionException is thrown.
Verifies that two objects are not equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are equal an AssertionException is thrown.
Verifies that two objects are not equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are equal an AssertionException is thrown.
Verifies that two objects are not equal. Two objects are considered
equal if both are null, or if both have the same value. NUnit
has special semantics for some object types.
If they are equal an AssertionException is thrown.
Asserts that two objects do not refer to the same object. If they
are the same an AssertionException is thrown.
Asserts that two objects do not refer to the same object. If they
are the same an AssertionException is thrown.
Asserts that two objects do not refer to the same object. If they
are the same an AssertionException is thrown.
Asserts that two objects refer to the same object. If they
are not the same an AssertionException is thrown.
Asserts that two objects refer to the same object. If they
are not the same an AssertionException is thrown.
Asserts that two objects refer to the same object. If they
are not the same an AssertionException is thrown.
protected static void AssertDoublesAreEqual(double expected, double actual, double delta, string message, object[] args)
Helper for Assert.AreEqual(double expected, double actual, ...)
allowing code generation to work consistently.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Used as a synonym for That in rare cases where a private setter
causes a Visual Basic compilation error.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Used as a synonym for That in rare cases where a private setter
causes a Visual Basic compilation error.
public static void ByVal(object actual, IResolveConstraint expression, string message, object[] args)
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Used as a synonym for That in rare cases where a private setter
causes a Visual Basic compilation error.
Verifies that a delegate throws an exception when called
and returns it.
Verifies that a delegate throws an exception when called
and returns it.
Verifies that a delegate throws an exception when called
and returns it.
public static Exception Catch(Type expectedExceptionType, TestDelegate code, string message, object[] args)
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Verifies that a delegate throws an exception of a certain Type
or one derived from it when called and returns it.
Asserts that an object is contained in a list.
Asserts that an object is contained in a list.
Asserts that an object is contained in a list.
Verifies that a delegate does not throw an exception
Verifies that a delegate does not throw an exception.
Verifies that a delegate does not throw an exception.
The Equals method throws an AssertionException. This is done
to make sure there is no mistake by calling this function.
Throws an AssertionException with the message and arguments
that are passed in. This is used by the other Assert functions.
Throws an AssertionException with the message that is
passed in. This is used by the other Assert functions.
Throws an AssertionException.
This is used by the other Assert functions.
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
public static void GreaterOrEqual(IComparable arg1, IComparable arg2, string message, object[] args)
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is greater than or equal tothe second
value. If it is not, then an
AssertionException is thrown.
Throws an IgnoreException with the message and arguments
that are passed in. This causes the test to be reported as ignored.
Throws an IgnoreException with the message that is
passed in. This causes the test to be reported as ignored.
Throws an IgnoreException.
This causes the test to be reported as ignored.
Throws an InconclusiveException with the message and arguments
that are passed in. This causes the test to be reported as inconclusive.
Throws an InconclusiveException with the message that is
passed in. This causes the test to be reported as inconclusive.
Throws an InconclusiveException.
This causes the test to be reported as Inconclusive.
Asserts that an object may be assigned a value of a given Type.
Asserts that an object may be assigned a value of a given Type.
Asserts that an object may be assigned a value of a given Type.
Asserts that an object may be assigned a value of a given Type.
Asserts that an object may be assigned a value of a given Type.
Asserts that an object may be assigned a value of a given Type.
Assert that a string is empty - that is equal to string.Empty
Assert that a string is empty - that is equal to string.Empty
Assert that a string is empty - that is equal to string.Empty
Assert that an array, list or other collection is empty
Assert that an array, list or other collection is empty
Assert that an array, list or other collection is empty
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Asserts that a condition is false. If the condition is true the method throws
an AssertionException.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Asserts that an object is an instance of a given type.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Verifies that the double that is passed in is an NaN value.
If the object is not NaN then an AssertionException
is thrown.
Asserts that an object may not be assigned a value of a given Type.
Asserts that an object may not be assigned a value of a given Type.
Asserts that an object may not be assigned a value of a given Type.
Asserts that an object may not be assigned a value of a given Type.
Asserts that an object may not be assigned a value of a given Type.
Asserts that an object may not be assigned a value of a given Type.
Assert that a string is not empty - that is not equal to string.Empty
Assert that a string is not empty - that is not equal to string.Empty
Assert that a string is not empty - that is not equal to string.Empty
Assert that an array, list or other collection is not empty
Assert that an array, list or other collection is not empty
Assert that an array, list or other collection is not empty
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Asserts that an object is not an instance of a given type.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Assert that a string is not null or empty
Assert that a string is not null or empty
Assert that a string is not null or empty
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
Assert that a string is either null or equal to string.Empty
Assert that a string is either null or equal to string.Empty
Assert that a string is either null or equal to string.Empty
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the first value is less than or equal to the second
value. If it is not, then an
AssertionException is thrown.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Verifies that the object that is passed in is not equal to null
If the object is null then an AssertionException
is thrown.
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
Verifies that the object that is passed in is equal to null
If the object is not null then an AssertionException
is thrown.
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.
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.
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.
override the default ReferenceEquals to throw an AssertionException. This
implementation makes sure there is no mistake in calling this function
as part of Assert.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
public static void That(object actual, IResolveConstraint expression, string message, object[] args)
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
public static void That(ActualValueDelegate del, IResolveConstraint expr, string message, object[] args)
Apply a constraint to an actual value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Apply a constraint to a referenced value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Apply a constraint to a referenced value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
public static void That<T>(ref T actual, IResolveConstraint expression, string message, object[] args)
Apply a constraint to a referenced value, succeeding if the constraint
is satisfied and throwing an assertion exception on failure.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that the code represented by a delegate throws an exception
that satisfies the constraint provided.
public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, object[] args)
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
public static Exception Throws(Type expectedExceptionType, TestDelegate code, string message, object[] args)
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Verifies that a delegate throws a particular exception when called.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.
Asserts that a condition is true. If the condition is false the method throws
an AssertionException.