I have discovered that these seem to be the two main ways of testing for exceptions:
Assert.Throws<Exception>(()=>MethodThatThrows());
[ExpectedException(typeof(Exception))]
Which of these would be best? Does one offer advantages over the other? Or is it simply a matter of personal preference?
Assert.That(() => MethodThatThrows(), Throws.Exception)
ExpectedException
attribute, so for version 3+ only theAssert.Throws
variant is relevant.