1public class Catch 2{ 3 public static Exception Exception(Action context) 4 { 5 try 6 { 7 context(); 8 } 9 catch (Exception thrownException) 10 { 11 return thrownException; 12 } 13 14 return null; 15 } 16}
Exception exception = Catch.Exception(() => [A action that will cause a eception]); exception.ShouldBeOfType<[Some Specific Exception]>();