public void Act() { Action TestCase(int testNumber, Action act, Type exceptionType, Type expectedExceptionType = null) => () => { var msg = "No." + testNumber; // Act TestActual testActual = default; Exception exception = null; try { testActual = TestAA.Act(act); } catch (Exception ex) { exception = ex; } // Assert if (exception == null) { Assert.AreEqual(typeof(TestActual), testActual.GetType(), msg); Assert.AreEqual(exceptionType, testActual.Exception?.GetType(), msg); } Assert.AreEqual(expectedExceptionType, exception?.GetType(), msg); }; foreach (var action in new[] {