static RunResult PerformTestRun(IList <EndpointBehaviour> behaviorDescriptors, IList <IScenarioVerification> shoulds, RunDescriptor runDescriptor, Func <ScenarioContext, bool> done) { var runResult = new RunResult { ScenarioContext = runDescriptor.ScenarioContext }; var runTimer = new Stopwatch(); runTimer.Start(); try { List <ActiveRunner> runners = InitializeRunners(runDescriptor, behaviorDescriptors); try { runResult.ActiveEndpoints = runners.Select(r => r.EndpointName).ToList(); PerformScenarios(runDescriptor, runners, () => done(runDescriptor.ScenarioContext)); } finally { UnloadAppDomains(runners); } runTimer.Stop(); Parallel.ForEach(runners, runner => shoulds.Where(s => s.ContextType == runDescriptor.ScenarioContext.GetType()).ToList() .ForEach(v => v.Verify(runDescriptor.ScenarioContext))); } catch (Exception ex) { runResult.Failed = true; runResult.Exception = ex; } runResult.TotalTime = runTimer.Elapsed; return(runResult); }
static async Task <RunResult> PerformTestRun(List <EndpointBehavior> behaviorDescriptors, List <IScenarioVerification> shoulds, RunDescriptor runDescriptor, Func <ScenarioContext, bool> done) { var runResult = new RunResult { ScenarioContext = runDescriptor.ScenarioContext }; var runTimer = new Stopwatch(); runTimer.Start(); try { var endpoints = await InitializeRunners(runDescriptor, behaviorDescriptors).ConfigureAwait(false); runResult.ActiveEndpoints = endpoints.Select(r => r.EndpointName).ToList(); await PerformScenarios(runDescriptor, endpoints, () => done(runDescriptor.ScenarioContext)).ConfigureAwait(false); runTimer.Stop(); foreach (var v in shoulds.Where(s => s.ContextType == runDescriptor.ScenarioContext.GetType())) { v.Verify(runDescriptor.ScenarioContext); } } catch (Exception ex) { runResult.Failed = true; runResult.Exception = ex; } runResult.TotalTime = runTimer.Elapsed; return(runResult); }
static RunResult PerformTestRun(IList<EndpointBehaviour> behaviorDescriptors, IList<IScenarioVerification> shoulds, RunDescriptor runDescriptor, Func<ScenarioContext, bool> done) { var runResult = new RunResult { ScenarioContext = runDescriptor.ScenarioContext }; var runTimer = new Stopwatch(); runTimer.Start(); try { List<ActiveRunner> runners = InitializeRunners(runDescriptor, behaviorDescriptors); try { runResult.ActiveEndpoints = runners.Select(r => r.EndpointName).ToList(); PerformScenarios(runDescriptor,runners, () => done(runDescriptor.ScenarioContext)); } finally { UnloadAppDomains(runners); } runTimer.Stop(); Parallel.ForEach(runners, runner => shoulds.Where(s => s.ContextType == runDescriptor.ScenarioContext.GetType()).ToList() .ForEach(v => v.Verify(runDescriptor.ScenarioContext))); } catch (Exception ex) { runResult.Failed = true; runResult.Exception = ex; } runResult.TotalTime = runTimer.Elapsed; return runResult; }
static async Task<RunResult> PerformTestRun(List<EndpointBehavior> behaviorDescriptors, List<IScenarioVerification> shoulds, RunDescriptor runDescriptor, Func<ScenarioContext, bool> done) { var runResult = new RunResult { ScenarioContext = runDescriptor.ScenarioContext }; var runTimer = new Stopwatch(); runTimer.Start(); try { var endpoints = await InitializeRunners(runDescriptor, behaviorDescriptors).ConfigureAwait(false); runResult.ActiveEndpoints = endpoints.Select(r => r.EndpointName).ToList(); await PerformScenarios(runDescriptor, endpoints, () => done(runDescriptor.ScenarioContext)).ConfigureAwait(false); runTimer.Stop(); foreach (var v in shoulds.Where(s => s.ContextType == runDescriptor.ScenarioContext.GetType())) { v.Verify(runDescriptor.ScenarioContext); } } catch (Exception ex) { runResult.Failed = true; runResult.Exception = ex; } runResult.TotalTime = runTimer.Elapsed; return runResult; }
static RunResult PerformTestRun(IList<EndpointBehavior> behaviorDescriptors, IList<IScenarioVerification> shoulds, RunDescriptor runDescriptor, Func<ScenarioContext, bool> done, Func<Exception, bool> allowedExceptions) { var runResult = new RunResult { ScenarioContext = runDescriptor.ScenarioContext }; var runTimer = new Stopwatch(); runTimer.Start(); try { var runners = InitializeRunners(runDescriptor, behaviorDescriptors); try { runResult.ActiveEndpoints = runners.Select(r => r.EndpointName).ToList(); PerformScenarios(runDescriptor, runners, () => { if (!string.IsNullOrEmpty(runDescriptor.ScenarioContext.Exceptions)) { var ex = new Exception(runDescriptor.ScenarioContext.Exceptions); if (!allowedExceptions(ex)) { throw new Exception("Failures in endpoints"); } } return done(runDescriptor.ScenarioContext); }); } finally { if (runDescriptor.UseSeparateAppdomains) { UnloadAppDomains(runners); } } runTimer.Stop(); Parallel.ForEach(runners, runner => { foreach (var v in shoulds.Where(s => s.ContextType == runDescriptor.ScenarioContext.GetType())) { v.Verify(runDescriptor.ScenarioContext); } }); } catch (Exception ex) { runResult.Failed = true; runResult.Exception = ex; } runResult.TotalTime = runTimer.Elapsed; return runResult; }