Upravit

Sdílet prostřednictvím


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

Throw an assertion exception with a message and optional arguments

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

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)

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, Object[])

Throws an IgnoreException with the message and arguments that are passed in. 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.

Inconclusive()

Throws an InconclusiveException. 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.

Inconclusive(String)

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

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

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, 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.

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)

Verifies that the object that is passed in is equal to null If the object is not null 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, 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.

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.

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

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)

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

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

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, String, Object[])
That<T>(ActualValueDelegate<T>, IResolveConstraint, String)
That<T>(ActualValueDelegate<T>, IResolveConstraint)
That<T>(T, IResolveConstraint, String, Object[])
That<T>(T, IResolveConstraint, String)
That<T>(T, IResolveConstraint)
Throws(IResolveConstraint, TestDelegate, String, Object[])
Throws(IResolveConstraint, TestDelegate, String)
Throws(IResolveConstraint, TestDelegate)
Throws(Type, TestDelegate, String, Object[])
Throws(Type, TestDelegate, String)
Throws(Type, TestDelegate)
Throws<T>(TestDelegate, String, Object[])
Throws<T>(TestDelegate, String)
Throws<T>(TestDelegate)
True(Boolean, String, Object[])

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)

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

Applies to