In the past I’ve used:
| |
to set an exception expectation and assert on the message. With the recent releases of NUnit I’ve finally transitioned all my code to use:
| |
or
| |
if the method has no parameters.
Only lately have I needed to capture the exception message and validate it. To do this you do the following:
| |
I am blogging about this because I keep forgetting how to capture the exception message. Hope it helps someone else.