Classic Model
The classic Assert model uses a separate method to express each individual assertion of which it is capable.
Here's a simple assert using the classic model:
StringAssert.AreEqualIgnoringCase("Hello", myString);
The Assert class provides the most common assertions in NUnit:
- ClassicAssert.True
- ClassicAssert.False
- ClassicAssert.Null
- ClassicAssert.NotNull
- ClassicAssert.Zero
- ClassicAssert.NotZero
- ClassicAssert.IsNaN
- ClassicAssert.IsEmpty
- ClassicAssert.IsNotEmpty
- ClassicAssert.AreEqual
- ClassicAssert.AreNotEqual
- ClassicAssert.AreSame
- ClassicAssert.AreNotSame
- ClassicAssert.Contains
- ClassicAssert.Greater
- ClassicAssert.GreaterOrEqual
- ClassicAssert.Less
- ClassicAssert.LessOrEqual
- ClassicAssert.Positive
- ClassicAssert.Negative
- ClassicAssert.IsInstanceOf
- ClassicAssert.IsNotInstanceOf
- ClassicAssert.IsAssignableFrom
- ClassicAssert.IsNotAssignableFrom
- Assert.Throws
- Assert.ThrowsAsync
- Assert.DoesNotThrow
- Assert.DoesNotThrowAsync
- Assert.Catch
- Assert.CatchAsync
Additional assertions are provided by the following classes, which are also in the NUnit.Framework.Legacy
namespace:
See Also
Notes
- The exception-family of classic asserts have not yet been moved to the legacy namespace. They have not yet full equivalents in the constraint model.