The Assert class contains a collection of static methods that mirror the most common assertions used in NUnit.
WORK IN PROGRESS. TEST RUNNER IS NOT FINISHED YET.
This class is mostly a drop-in replacement for "old-style" NUnit tests, i.e. those that do not use constraint classes or the "Is" class.
Some methods were dropped to keep this class small. Use the full NUnit framework if the remaining methods are not sufficient for you.
-
When the same assertion was known by multiple similar names (e.g. True and IsTrue), I kept only one of the names. However, I did keep That(), Expect() and IsTrue() even though they all do the same thing.
-
Some less-common overloads that take a format string and arguments were dropped.
-
Some overloads were dropped when the compiler can automatically select a different overload instead. In particular, most overloads that take a message string (without arguments) were dropped. Code that relied on those overloads will still compile, because the compiler will construct an empty argument list and call the overload that takes a variable argument list.
|
static void | Fail (string format, params object[] args) |
| Fails a test via StopTestHandler, which, by default, throws an AssertionException. More...
|
|
static void | Fail (string message) |
| Fails a test by invoking StopTestHandler.Value(), which, by default, throws an AssertionException. More...
|
|
static void | Ignore (string format, params object[] args) |
| Stops a test via StopTestHandler, which, by default, throws an IgnoreException. This causes the test to be reported as ignored. More...
|
|
static void | Inconclusive (string format, params object[] args) |
| Stops a test via StopTestHandler, which, by default, throws an InconclusiveException. This causes the test to be reported as inconclusive. More...
|
|
static void | Success (string format, params object[] args) |
| Stops a test via StopTestHandler, which, by default, throws a SuccessException. More...
|
|
static void | Fail () |
| Short for Fail(""). More...
|
|
static void | Ignore () |
| Short for Ignore(""). More...
|
|
static void | Inconclusive () |
| Short for Inconclusive(""). More...
|
|
static void | Success () |
| Short for Success(""). More...
|
|
static new void | Equals (object a, object b) |
| Equals() is inherited from object; you probably want to call AreEqual instead. More...
|
|
static new void | ReferenceEquals (object a, object b) |
| Verifies that two references are equal. More...
|
|
static void | That (bool condition, string message, params object[] args) |
| Calls Fail(message, args) if condition is false. More...
|
|
static void | That (bool condition, string message) |
| Calls Fail(message) if condition is false. More...
|
|
static void | That (bool condition) |
| Calls Fail() if condition is false. More...
|
|
static void | Expect (bool condition) |
| Calls Fail() if condition is false. More...
|
|
static Exception | Throws (Type expectedExceptionType, Action code, string message, params object[] args) |
| Verifies that a delegate throws a particular exception when called. More...
|
|
static Exception | Throws (Type expectedExceptionType, Action code) |
|
static T | Throws< T > (Action code, string message, params object[] args) |
|
static T | Throws< T > (Action code) |
|
static Exception | Catch (Action code, string message, params object[] args) |
| Verifies that a delegate throws an exception when called and returns it. More...
|
|
static Exception | Catch (Action code) |
| Verifies that a delegate throws an exception when called and returns it. More...
|
|
static void | DoesNotThrow (Action code, string message, params object[] args) |
| Verifies that a delegate does not throw an exception More...
|
|
static void | DoesNotThrow (Action code) |
| Verifies that a delegate does not throw an exception. More...
|
|
static void | IsTrue (bool condition, string message, params object[] args) |
|
static void | IsTrue (bool condition) |
|
static void | IsFalse (bool condition, string message, params object[] args) |
|
static void | IsFalse (bool condition) |
|
static void | IsNotNull (object anObject, string message, params object[] args) |
|
static void | IsNotNull (object anObject) |
|
static void | IsNull (object anObject, string message, params object[] args) |
|
static void | IsNull (object anObject) |
|
static void | IsNaN (double aDouble) |
|
static void | IsEmpty (string aString) |
|
static void | IsEmpty (System.Collections.IEnumerable collection) |
|
static void | IsNotEmpty (System.Collections.IEnumerable collection) |
|
static void | IsNullOrEmpty (string aString) |
|
static void | IsNotNullOrEmpty (string aString) |
|
static void | IsInstanceOf (Type expected, object actual) |
|
static void | IsNotInstanceOf (Type expected, object actual) |
|
static void | IsInstanceOf< T > (object actual) |
|
static void | IsNotInstanceOf< T > (object actual) |
|
static void | AreEqual (long expected, long actual, string message, params object[] args) |
|
static void | AreEqual (ulong expected, ulong actual, string message, params object[] args) |
|
static void | AreEqual (int expected, int actual) |
|
static void | AreEqual (long expected, long actual) |
|
static void | AreEqual (ulong expected, ulong actual) |
|
static void | AreEqual (decimal expected, decimal actual) |
|
static void | AreEqual (double expected, double actual, double delta, string message, params object[] args) |
|
static void | AreEqual (double expected, double actual, double delta) |
|
static void | AreEqual (double expected, double actual) |
|
static void | AreEqual (object expected, object actual, string message, params object[] args) |
|
static void | AreEqual (object expected, object actual) |
|
static void | AreNotEqual (long expected, long actual, string message, params object[] args) |
|
static void | AreNotEqual (ulong expected, ulong actual, string message, params object[] args) |
|
static void | AreNotEqual (int expected, int actual) |
|
static void | AreNotEqual (long expected, long actual) |
|
static void | AreNotEqual (ulong expected, ulong actual) |
|
static void | AreNotEqual (decimal expected, decimal actual) |
|
static void | AreNotEqual (double expected, double actual, double delta, string message, params object[] args) |
|
static void | AreNotEqual (double expected, double actual, double delta) |
|
static void | AreNotEqual (object expected, object actual, string message, params object[] args) |
|
static void | AreNotEqual (object expected, object actual) |
|
static void | AreSame (object expected, object actual, string message, params object[] args) |
|
static void | AreSame (object expected, object actual) |
|
static void | AreNotSame (object expected, object actual, string message, params object[] args) |
|
static void | AreNotSame (object expected, object actual) |
|
static void | Greater (long arg1, long arg2, string message, params object[] args) |
|
static void | Greater (double arg1, double arg2, string message, params object[] args) |
|
static void | Greater (IComparable arg1, IComparable arg2, string message, params object[] args) |
|
static void | Greater (int arg1, int arg2) |
|
static void | Greater (long arg1, long arg2) |
|
static void | Greater (double arg1, double arg2) |
|
static void | Greater (IComparable arg1, IComparable arg2) |
|
static void | Less (long arg1, long arg2, string message, params object[] args) |
|
static void | Less (double arg1, double arg2, string message, params object[] args) |
|
static void | Less (IComparable arg1, IComparable arg2, string message, params object[] args) |
|
static void | Less (int arg1, int arg2) |
|
static void | Less (long arg1, long arg2) |
|
static void | Less (double arg1, double arg2) |
|
static void | Less (IComparable arg1, IComparable arg2) |
|
static void | GreaterOrEqual (long arg1, long arg2, string message, params object[] args) |
|
static void | GreaterOrEqual (double arg1, double arg2, string message, params object[] args) |
|
static void | GreaterOrEqual (IComparable arg1, IComparable arg2, string message, params object[] args) |
|
static void | GreaterOrEqual (int arg1, int arg2) |
|
static void | GreaterOrEqual (long arg1, long arg2) |
|
static void | GreaterOrEqual (double arg1, double arg2) |
|
static void | GreaterOrEqual (IComparable arg1, IComparable arg2) |
|
static void | LessOrEqual (long arg1, long arg2, string message, params object[] args) |
|
static void | LessOrEqual (double arg1, double arg2, string message, params object[] args) |
|
static void | LessOrEqual (IComparable arg1, IComparable arg2, string message, params object[] args) |
|
static void | LessOrEqual (int arg1, int arg2) |
|
static void | LessOrEqual (long arg1, long arg2) |
|
static void | LessOrEqual (double arg1, double arg2) |
|
static void | LessOrEqual (IComparable arg1, IComparable arg2) |
|
static void | Contains (object expected, IEnumerable actual, string message, params object[] args) |
| Asserts that an object is contained in a list. More...
|
|
static void | Contains (object expected, IEnumerable actual) |
| Asserts that an object is contained in a list. More...
|
|