void AddWarnings(TestResultCollection result) { result.AddWarnings(Warnings); foreach (var test in tests) { result.AddWarnings(test.Warnings); } }
public async Task <TestResult> Run(TestContext context, CancellationToken cancellationToken) { var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); if (Attribute.Timeout > 0) { cts.CancelAfter(Attribute.Timeout); } var oldConfig = context.Configuration; try { context.Configuration = Configuration; var attr = Method.GetCustomAttribute <ExpectedExceptionAttribute> (); TestResult result; if (attr != null) { result = await ExpectingException(context, attr.ExpectedException, cts.Token); } else { result = await ExpectingSuccess(context, cts.Token); } if (!context.HasWarnings) { return(result); } var collection = new TestResultCollection(result.Name); collection.AddChild(result); collection.AddWarnings(context.Warnings); return(collection); } catch (Exception ex) { Log("Test {0} failed: {1}", Name, ex); return(new TestError(Name, null, ex)); } finally { context.Configuration = oldConfig; } }
void AddWarnings (TestResultCollection result) { result.AddWarnings (Warnings); foreach (var test in tests) { result.AddWarnings (test.Warnings); } }
public async Task<TestResult> Run (TestContext context, CancellationToken cancellationToken) { var cts = CancellationTokenSource.CreateLinkedTokenSource (cancellationToken); if (Attribute.Timeout > 0) cts.CancelAfter (Attribute.Timeout); var oldConfig = context.Configuration; try { context.Configuration = Configuration; var attr = Method.GetCustomAttribute<ExpectedExceptionAttribute> (); TestResult result; if (attr != null) result = await ExpectingException (context, attr.ExceptionType, cts.Token); else result = await ExpectingSuccess (context, cts.Token); if (!context.HasWarnings) return result; var collection = new TestResultCollection (result.Name); collection.AddChild (result); collection.AddWarnings (context.Warnings); return collection; } catch (Exception ex) { Log ("Test {0} failed: {1}", Name, ex); return new TestError (Name, null, ex); } finally { context.Configuration = oldConfig; } }