public static async Task RunExpectingException <T>(this IContextualTestClass provider, Func <Task> action, [CallerMemberName] string callerMemberName = "") where T : Exception { try { await action(); } catch (T caughtException) { Type exceptionType = caughtException.GetType(); provider.TestContext.WriteLine($"Run {nameof(RunExpectingException)} successful. Caught Exception of type {exceptionType.FullName}."); } }
public TestTelemetron(IContextualTestClass testclass, ITestTelemetronConfiguration configuration) : base(configuration) { if (testclass == null) { throw new ArgumentNullException(nameof(testclass)); } if (testclass.TestContext == null) { throw new ArgumentNullException(nameof(testclass) + '.' + nameof(testclass.TestContext)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } this.EmitTestName = configuration.EmitTestName; this.EmitCurrentTestOutcome = configuration.EmitCurrentTestOutcome; this.testContext = testclass; }