public static void Throw <T> (TestSnippet snippet, string message) where T : Exception { try { snippet(); } catch (Exception e) { if (e.GetType() == typeof(T)) { return; } throw new Exception(String.Format("{0}: Invalid exception type. Expected '{1}' got '{2}'", message, typeof(T), e.GetType())); } throw new Exception(String.Format("{0}: No exception thrown.", message)); }
public static void NotThrow(TestSnippet snippet) { snippet(); }