If we do a
throw new ArgumentException("Cannot do that");
How do you Assert that this ArgumentException
happened with Microsoft's Testing Framework?
You could decorate your unit test with the [ExpectedException]
attribute:
[ExpectedException(typeof(ArgumentException))]
[TestMethod]
public void Foo()
{
throw new ArgumentException("foo");
}
Don't ask though about asserting the exception message :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With