The first line of the document looks pretty clear:
Assert.Catch is similar to Assert.Throws , but will throw an exception that is thrown from the specified one.
Thus, use Assert.Catch if the exception obtained from the specified exception is valid (this means that it will also be caught in the equivalent catch ).
The documentation for Assert.Throws provides examples of both:
// Require an ApplicationException - derived types fail! Assert.Throws( typeof(ApplicationException), code ); Assert.Throws<ApplicationException>()( code ); // Allow both ApplicationException and any derived type Assert.Throws( Is.InstanceOf( typeof(ApplicationException), code ); Assert.Throws( Is.InstanceOf<ApplicationException>;(), code ); // Allow both ApplicationException and any derived type Assert.Catch<ApplicationException>( code ); // Allow any kind of exception Assert.Catch( code );
D Stanley
source share