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;
}