Methods that test a specific condition are named for the condition they test and take the value tested as their first argument and, optionally a message as the second. The following methods are provided:
Assert.IsTrue( bool condition ); Assert.IsTrue( bool condition, string message ); Assert.IsTrue( bool condition, string message, object[] parms ); Assert.True( bool condition ); Assert.True( bool condition, string message ); Assert.True( bool condition, string message, object[] parms ); Assert.IsFalse( bool condition); Assert.IsFalse( bool condition, string message ); Assert.IsFalse( bool condition, string message, object[] parms ); Assert.False( bool condition); Assert.False( bool condition, string message ); Assert.False( bool condition, string message, object[] parms ); Assert.IsNull( object anObject ); Assert.IsNull( object anObject, string message ); Assert.IsNull( object anObject, string message, object[] parms ); Assert.Null( object anObject ); Assert.Null( object anObject, string message ); Assert.Null( object anObject, string message, object[] parms ); Assert.IsNotNull( object anObject ); Assert.IsNotNull( object anObject, string message ); Assert.IsNotNull( object anObject, string message, object[] parms ); Assert.NotNull( object anObject ); Assert.NotNull( object anObject, string message ); Assert.NotNull( object anObject, string message, object[] parms ); Assert.IsNaN( double aDouble ); Assert.IsNaN( double aDouble, string message ); Assert.IsNaN( double aDouble, string message, object[] parms ); Assert.IsEmpty( string aString ); Assert.IsEmpty( string aString, string message ); Assert.IsEmpty( string aString, string message, params object[] args ); Assert.IsNotEmpty( string aString ); Assert.IsNotEmpty( string aString, string message ); Assert.IsNotEmpty( string aString, string message, params object[] args ); Assert.IsEmpty( ICollection collection ); Assert.IsEmpty( ICollection collection, string message ); Assert.IsEmpty( ICollection collection, string message, params object[] args ); Assert.IsNotEmpty( ICollection collection ); Assert.IsNotEmpty( ICollection collection, string message ); Assert.IsNotEmpty( ICollection collection, string message, params object[] args );
Two forms are provided for the True, False, Null and NotNull conditions. The "Is" forms are compatible with earlier versions of the NUnit framework, while those without "Is" are provided for compatibility with NUnitLite.
Assert.IsEmpty and Assert.IsNotEmpty may be used to test either a string or a collection.