async Task<TestResult> ExpectingException (TestContext context, Type type, CancellationToken cancellationToken) { try { await context.Invoke (this, cancellationToken); var message = string.Format ("Expected an exception of type {0}", type); return new TestError (Name, message, new AssertionException (message)); } catch (Exception ex) { if (ex is TargetInvocationException) ex = ((TargetInvocationException)ex).InnerException; if (type.IsAssignableFrom (ex.GetType ())) return new TestSuccess (Name); var message = string.Format ("Expected an exception of type {0}, but got {1}", type, ex.GetType ()); return new TestError (Name, message, new AssertionException (message, ex)); } }
async Task<TestResult> ExpectingSuccess (TestContext context, CancellationToken cancellationToken) { await context.Invoke (this, cancellationToken); return new TestSuccess (Name); }