internal TestResultSummary(TestResult testResult, ITestOutcomeFilter outcomeFilter) { TestResult = testResult; Successes = TestResult.Outcomes.Count(o => o.Exception == null); Failures = TestResult.Outcomes.Count() - Successes; var eligibleOutcomes = outcomeFilter.Filter(TestResult.Outcomes); if (eligibleOutcomes.Any()) { AverageExecutionTime = eligibleOutcomes.Average(o => o.Elapsed.TotalMilliseconds); } }
/// <summary> /// Executes the action delegate as many time as necessary and returns the result /// </summary> public ITestResult GetResult() { // get all the test outcomes for all the test runs var outcomes = Enumerable.Range(1, Count).Select(i => Execute()).ToList(); // compose the test result var result = new TestResult(this, outcomes); // attach event handler for when a new result summary becomes available result.OnNewTestResultSummary += OnNewTestResultSummaryHanlder; // and fire an event to notify others that a new test result is available OnNewTestResult(this, new NewTestResultEventArgs(this, result)); // return the test result return result; }