Search Results for

    Show / Hide Table of Contents

    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:

    • String Assert
    • Collection Assert
    • File Assert
    • Directory Assert

    See Also

    • Constraint Model

    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.
    • Edit this page
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0