Testing thrown exceptions (ArgumentException)

While creating some unit tests I wanted to make sure that the correct exception was being thrown and as I was testing for ArgumentExceptions that the correct parameter was causing the ArgumentException. So after referring to my developers guide aka Google. I came across a post on StackOverflow

A small example from the post: -

var ex = Assert.Throws<ArgumentNullException>(() => foo.Bar(null));
Assert.That(ex.ParamName, Is.EqualTo("bar"));

0 comments: