<PackageReference Include="NUnit" Version="3.0.0-rc-2" />

Assert

public class Assert
The Assert class contains a collection of static methods that implement the most common assertions used in NUnit.
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.

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.

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

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.

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

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(object expected, object actual, string message, object[] args)

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.

public static void AreEqual(object expected, object actual)

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.

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

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.

public static void AreNotEqual(object expected, object actual)

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.

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

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

public static void AreNotSame(object expected, object actual)

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

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

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)

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.

public static void ByVal(object actual, IResolveConstraint expression)

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.

public static Exception Catch(TestDelegate code, string message, object[] args)

Verifies that a delegate throws an exception when called and returns it.

public static Exception Catch(TestDelegate code)

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.

public static Exception Catch(Type expectedExceptionType, TestDelegate code)

Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it.

public static TActual Catch<TActual>(TestDelegate code, string message, object[] args) where TActual : Exception

Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it.

public static TActual Catch<TActual>(TestDelegate code) where TActual : Exception

Verifies that a delegate throws an exception of a certain Type or one derived from it when called and returns it.

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

Asserts that an object is contained in a list.

public static void Contains(object expected, ICollection actual)

Asserts that an object is contained in a list.

public static void DoesNotThrow(TestDelegate code, string message, object[] args)

Verifies that a delegate does not throw an exception

public static void DoesNotThrow(TestDelegate code)

Verifies that a delegate does not throw an exception.

public static bool Equals(object a, object b)

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

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

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)

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

public static void Fail()

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

public static void False(bool? condition, string message, object[] args)

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

public static void False(bool condition, string message, object[] args)

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

public static void False(bool? condition)

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

public static void False(bool condition)

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

public static void Greater(int arg1, int arg2, string message, object[] args)

Verifies that the first int is greater than the second int. If it is not, then an AssertionException is thrown.

public static void Greater(int arg1, int arg2)

Verifies that the first int is greater than the second int. If it is not, then an AssertionException is thrown.

public static void Greater(uint arg1, uint arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(uint arg1, uint arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(long arg1, long arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(long arg1, long arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(ulong arg1, ulong arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(ulong arg1, ulong arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(decimal arg1, decimal arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(decimal arg1, decimal arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(double arg1, double arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(double arg1, double arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(float arg1, float arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(float arg1, float arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(IComparable arg1, IComparable arg2, string message, object[] args)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void Greater(IComparable arg1, IComparable arg2)

Verifies that the first value is greater than the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(int arg1, int arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(int arg1, int arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(uint arg1, uint arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(uint arg1, uint arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(long arg1, long arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(long arg1, long arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(ulong arg1, ulong arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(ulong arg1, ulong arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(decimal arg1, decimal arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(decimal arg1, decimal arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(double arg1, double arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(double arg1, double arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(float arg1, float arg2, string message, object[] args)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(float arg1, float arg2)

Verifies that the first value is greater than or equal to the 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 to the second value. If it is not, then an AssertionException is thrown.

public static void GreaterOrEqual(IComparable arg1, IComparable arg2)

Verifies that the first value is greater than or equal to the second value. If it is not, then an AssertionException is thrown.

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

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)

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

public static void Ignore()

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

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

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

public static void Inconclusive(string message)

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

public static void Inconclusive()

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

public static void IsAssignableFrom(Type expected, object actual, string message, object[] args)

Asserts that an object may be assigned a value of a given Type.

public static void IsAssignableFrom(Type expected, object actual)

Asserts that an object may be assigned a value of a given Type.

public static void IsAssignableFrom<TExpected>(object actual, string message, object[] args)

Asserts that an object may be assigned a value of a given Type.

public static void IsAssignableFrom<TExpected>(object actual)

Asserts that an object may be assigned a value of a given Type.

public static void IsEmpty(string aString, string message, object[] args)

Assert that a string is empty - that is equal to string.Empty

public static void IsEmpty(string aString)

Assert that a string is empty - that is equal to string.Empty

public static void IsEmpty(IEnumerable collection, string message, object[] args)

Assert that an array, list or other collection is empty

public static void IsEmpty(IEnumerable collection)

Assert that an array, list or other collection is empty

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

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

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

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

public static void IsFalse(bool? condition)

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

public static void IsFalse(bool condition)

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

public static void IsInstanceOf(Type expected, object actual, string message, object[] args)

Asserts that an object is an instance of a given type.

public static void IsInstanceOf(Type expected, object actual)

Asserts that an object is an instance of a given type.

public static void IsInstanceOf<TExpected>(object actual, string message, object[] args)

Asserts that an object is an instance of a given type.

public static void IsInstanceOf<TExpected>(object actual)

Asserts that an object is an instance of a given type.

public static void IsNaN(double aDouble, string message, object[] args)

Verifies that the double that is passed in is an NaN value. If the object is not NaN then an AssertionException is thrown.

public static void IsNaN(double aDouble)

Verifies that the double that is passed in is an NaN value. If the object is not NaN then an AssertionException is thrown.

public static void IsNaN(double? aDouble, string message, object[] args)

Verifies that the double that is passed in is an NaN value. If the object is not NaN then an AssertionException is thrown.

public static void IsNaN(double? aDouble)

Verifies that the double that is passed in is an NaN value. If the object is not NaN then an AssertionException is thrown.

public static void IsNotAssignableFrom(Type expected, object actual, string message, object[] args)

Asserts that an object may not be assigned a value of a given Type.

public static void IsNotAssignableFrom(Type expected, object actual)

Asserts that an object may not be assigned a value of a given Type.

public static void IsNotAssignableFrom<TExpected>(object actual, string message, object[] args)

Asserts that an object may not be assigned a value of a given Type.

public static void IsNotAssignableFrom<TExpected>(object actual)

Asserts that an object may not be assigned a value of a given Type.

public static void IsNotEmpty(string aString, string message, object[] args)

Assert that a string is not empty - that is not equal to string.Empty

public static void IsNotEmpty(string aString)

Assert that a string is not empty - that is not equal to string.Empty

public static void IsNotEmpty(IEnumerable collection, string message, object[] args)

Assert that an array, list or other collection is not empty

public static void IsNotEmpty(IEnumerable collection)

Assert that an array, list or other collection is not empty

public static void IsNotInstanceOf(Type expected, object actual, string message, object[] args)

Asserts that an object is not an instance of a given type.

public static void IsNotInstanceOf(Type expected, object actual)

Asserts that an object is not an instance of a given type.

public static void IsNotInstanceOf<TExpected>(object actual, string message, object[] args)

Asserts that an object is not an instance of a given type.

public static void IsNotInstanceOf<TExpected>(object actual)

Asserts that an object is not an instance of a given type.

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

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

public static void IsNotNull(object anObject)

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

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

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

public static void IsNull(object anObject)

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

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

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

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

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

public static void IsTrue(bool? condition)

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

public static void IsTrue(bool condition)

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

public static void Less(int arg1, int arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(int arg1, int arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(uint arg1, uint arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(uint arg1, uint arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(long arg1, long arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(long arg1, long arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(ulong arg1, ulong arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(ulong arg1, ulong arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(decimal arg1, decimal arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(decimal arg1, decimal arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(double arg1, double arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(double arg1, double arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(float arg1, float arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(float arg1, float arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(IComparable arg1, IComparable arg2, string message, object[] args)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void Less(IComparable arg1, IComparable arg2)

Verifies that the first value is less than the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(int arg1, int arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(int arg1, int arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(uint arg1, uint arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(uint arg1, uint arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(long arg1, long arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(long arg1, long arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(ulong arg1, ulong arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(ulong arg1, ulong arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(decimal arg1, decimal arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(decimal arg1, decimal arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(double arg1, double arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(double arg1, double arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(float arg1, float arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(float arg1, float arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(IComparable arg1, IComparable arg2, string message, object[] args)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void LessOrEqual(IComparable arg1, IComparable arg2)

Verifies that the first value is less than or equal to the second value. If it is not, then an AssertionException is thrown.

public static void Multiple(TestDelegate del)

If an assert fails within this block, execution will continue and the errors will be reported at the end of the block.

public static void NotNull(object anObject, string message, object[] args)

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

public static void NotNull(object anObject)

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

public static void Null(object anObject, string message, object[] args)

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

public static void Null(object anObject)

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

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

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.

public static void Pass(string message)

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.

public static void 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.

public static void ReferenceEquals(object a, object b)

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

public static void That(bool condition, string message, object[] args)

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

public static void That(bool condition)

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

public static void That(Func<bool> condition, string message, object[] args)

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

public static void That(Func<bool> condition)

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

public static void That<TActual>(ActualValueDelegate<TActual> del, IResolveConstraint expr)

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

public static void That<TActual>(ActualValueDelegate<TActual> 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.

public static void That(TestDelegate code, IResolveConstraint constraint)

Asserts that the code represented by a delegate throws an exception that satisfies the constraint provided.

public static void That(TestDelegate code, IResolveConstraint constraint, string message, string[] args)

Asserts that the code represented by a delegate throws an exception that satisfies the constraint provided.

public static void That<TActual>(TActual actual, IResolveConstraint expression)

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

public static void That<TActual>(TActual 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.

public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message, object[] args)

Verifies that a delegate throws a particular exception when called.

public static Exception Throws(IResolveConstraint expression, TestDelegate code)

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.

public static Exception Throws(Type expectedExceptionType, TestDelegate code)

Verifies that a delegate throws a particular exception when called.

public static TActual Throws<TActual>(TestDelegate code, string message, object[] args) where TActual : Exception

Verifies that a delegate throws a particular exception when called.

public static TActual Throws<TActual>(TestDelegate code) where TActual : Exception

Verifies that a delegate throws a particular exception when called.

public static void True(bool? condition, string message, object[] args)

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

public static void True(bool condition, string message, object[] args)

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

public static void True(bool? condition)

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

public static void True(bool condition)

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