C#, NUnit: Clear way of testing that ArgumentException has correct ParamName

c#, exception, nunit, properties

Solution

Found a pretty clear way (but please let me know if anyone have an even better one!)

var e = Assert.Throws<ArgumentException>(() => dog.BarkAt(deafDog));
Assert.That(e.ParamName, Is.EqualTo("otherDog"));

Facepalm...

Problem

To test that something throws for example an `ArgumentException` I can do this: ``` Assert.Throws<ArgumentException>(() => dog.BarkAt(deafDog)); ``` How can I check that the `ParamName` is correct in a clear way? And bonus question: Or would you perhaps perhaps recommend not testing this at all?

Original source