NUnit 2.5.10 Legacy Documentation. View NUnit 3 Documentation

Type Asserts (NUnit 2.2.3 / 2.5)

These methods allow us to make assertions about the type of an object.


Assert.IsInstanceOfType( Type expected, object actual );
Assert.IsInstanceOfType( Type expected, object actual, 
                string message );
Assert.IsInstanceOfType( Type expected, object actual, 
                string message, params object[] parms );
				
Assert.IsNotInstanceOfType( Type expected, object actual );
Assert.IsNotInstanceOfType( Type expected, object actual, 
                string message );
Assert.IsNotInstanceOfType( Type expected, object actual, 
                string message, params object[] parms );
			
Assert.IsAssignableFrom( Type expected, object actual );
Assert.IsAssignableFrom( Type expected, object actual, 
                string message );
Assert.IsAssignableFrom( Type expected, object actual, 
                string message, params object[] parms );
				
Assert.IsNotAssignableFrom( Type expected, object actual );
Assert.IsNotAssignableFrom( Type expected, object actual, 
                string message );
Assert.IsNotAssignableFrom( Type expected, object actual, 
                string message, params object[] parms );
				
Beginning with NUnit 2.5, generic equivalents are available in .NET 2.0 NUnit packages.

Assert.IsInstanceOf<T>( object actual );
Assert.IsInstanceOf<T>( object actual, string message );
Assert.IsInstanceOf<T>( object actual, 
                string message, params object[] parms );
				
Assert.IsNotInstanceOf<T>( object actual );
Assert.IsNotInstanceOf<T>( object actual, string message ); 
Assert.IsNotInstanceOf<T>( object actual, 
                string message, params object[] parms );
			
Assert.IsAssignableFrom<T>( object actual );
Assert.IsAssignableFrom<T>( object actual, string message );
Assert.IsAssignableFrom<T>( object actual, 
                string message, params object[] parms );
				
Assert.IsNotAssignableFrom<T>( object actual );
Assert.IsNotAssignableFrom<T>( object actual, string message );
Assert.IsNotAssignableFrom<T>( object actual, 
                string message, params object[] parms );