public static class Must { public static void Throw<T>(Action action) where T : Exception { if (action == null) throw new ArgumentNullException("action"); try { action(); Assert.Fail("action() did not throw expected exception " + typeof(T).ToString() + "."); } catch (Exception e) { Assert.AreEqual(typeof(T), e.GetType()); } } }