Perhaps I haven't looked enough but I really miss Assert.Throws in MSTest. Or does it exist? I've seen more people look for it.... For me, I just put together something real quick.
[DebuggerStepThrough()]
public static T Throws<T>(Action action) where T : Exception
{
try
{
action.Invoke();
}
catch (T ex)
{
return ex;
}
catch (Exception ex)
{
throw new AssertFailedException(string.Format(
"Expected exception was not thrown! Got: '{0}'.",
ex.GetType()), ex);
}
throw new AssertFailedException(
"Expected exception was not thrown! None was thrown.");
}
//Daniel