The unit tests for NUnit contain an
interesting pattern for verifying exception details. The abstract
class
MessageChecker
in assembly nunit.framework.tests implements
IExpectException,
an interface introduced with NUnit 2.4. Test cases in derived test
fixtures set the protected field expectedMessage to the expected
exception message which can span several lines or include data from
the test setup. Here is another example: