Assert Class

Summary

The Assert class contains a collection of static methods that implement the assertions used in TC-Lite.
Namespace
TCLite
Base Types
  • object
graph BT Type-->Base0["object"] Type["Assert"] class Type type-node

Syntax

public abstract class Assert

Remarks

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 use of abstract in the declaration.

Methods

Name Value Summary
AreEqual(double, double, double, string, object[]) void
Asserts that two doubles are equal within the specified tolerance. If not, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreEqual(double, double?, double, string, object[]) void
Asserts that two doubles are equal within the specified tolerance. If not, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreEqual(object, object, string, object[]) void
Asserts that two instances of a type are equal. If not, then a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreEqual<T1, T2>(T1, T2, string, object[]) void
Asserts that two instances of a type are equal. If not, then a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreNotEqual<T>(T, T, string, object[]) void
Asserts that two instances of a type are not equal. If equal, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreNotSame<T>(T, T, string, object[]) void
Asserts that two references do not refer to the same instance. If they do, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
AreSame<T>(T, T, string, object[]) void
Asserts that two references refer to the same instance of a Type. If not, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
DoesNotThrow(TestDelegate, string, object[]) void
Asserts that a delegate does not throw an exception. If any exception is thrown, it is caught and a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
Equals(object, object) bool
The Equals method is overridden to throw a System.InvalidOperationException. This is done to make sure there is no mistake by calling it when Assert.AreEqual(object, object) is actually intended.
static
Fail(string, object[]) void
Throws a TCLite.AssertionException with the message and arguments provided, ending the running test immediately and reporting it as a Failure.
static
Ignore(string, object[]) void
Throws a TCLite.IgnoreException with the message and arguments provided, ending the running test immediately and reporting it as Ignored.
static
Inconclusive(string, object[]) void
Throws a TCLite.InconclusiveException with the message and arguments provided, ending the running test immediately. The test is reported as Inconclusive unless Warnings were previously recorded.
static
IsEmpty(IEnumerable, string, object[]) void
Asserts that an array, list, collection or enumeration is empty. If it is not empty a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsEmpty(string, string, object[]) void
Asserts that a string is empty. If the string is not empty a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsFalse(bool, string, object[]) void
Asserts that a condition is false. If the condition is true the method throws a TCLite.AssertionException, ending the running test and reporting it as a Failure.
static
IsNotEmpty(IEnumerable, string, object[]) void
Asserts that an array, list, collection or enumeration is not empty. If it is empty a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsNotEmpty(string, string, object[]) void
Asserts that a string is not empty. If the string is empty a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsNotNull(object, string, object[]) void
Asserts that an object is not null. If the object is null a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsNull(object, string, object[]) void
Asserts that an object is null. If the object is not null a TCLite.AssertionException is thrown, ending the running test and reporting it as a Failure.
static
IsTrue(bool, string, object[]) void
Asserts that a condition is true. If the condition is false the method throws a TCLite.AssertionException, ending the running test and reporting it as a Failure.
static
Pass(string, object[]) void
Throws a TCLite.SuccessException with the message and arguments provided, ending the running test immediately and reporting it as successful.
static
ReferenceEquals(object, object) bool
The ReferenceEquals method is overridden to throw a System.InvalidOperationException. This ensures that there there is no mistake in calling this function rather than Assert.AreSame(object, object).
static
That(bool, string, object[]) void
Asserts that a condition is true. If the condition is false the method throws a TCLite.AssertionException, ending the running test and reporting it as a Failure.
static
That<T>(ActualValueDelegate<T>, IResolveConstraint, string, object[]) void
Apply a constraint to a TCLite.ActualValueDelegate, succeeding if the constraint is satisfied and throwing an assertion exception on failure.
static
That<T>(T, IResolveConstraint, string, object[]) void
Apply a constraint to an actual value, succeeding if the constraint is satisfied and throwing an assertion exception on failure.
static
That<T>(T, IResolveConstraint, string, object[]) void
Apply a constraint to a referenced value, succeeding if the constraint is satisfied and throwing an assertion exception on failure.
static
Throws(IResolveConstraint, TestDelegate, string, object[]) Exception
Asserts that a delegate throws an exception, which satisfies a provided Constraint. If no exception is thrown or if the constraint is not satisfied, then a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
Throws(Type, TestDelegate, string, object[]) Exception
Asserts that a delegate throws an exception of the Type specified. If no exception is thrown or if it is of the wrong Type, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
Throws<T>(TestDelegate, string, object[]) T
Asserts that a delegate throws an exception of the Type specified. If no exception is thrown or if it is of the wrong Type, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
static
Warn(string, object[]) void
Records a warning message and continues running the test. If the test eventually completes without failing, it will be reported with a Warning result.
static