I am trying to avoid a brittle test. I'd like to assert that a method throws an exception when invalid data is passed in, and I don't care which one.
Take String.IsNullOrEmpty for instance, if the string is empty you don't want to throw a nullreference exception right? if it's null you I suppose you could throw an argumentException. I don't think having a seperate guard clause for null vs empty is a good idea, and regardless I'd like to be able to just assert that an exception is thrown from my unit.
using [ExpectedException(typeof(Exception))]
gives an error saying the exception type must inherit from exception. My solution is a try/catch block with an Assert.Fail if no exception is thrown. Is there a better/cleaner way?