예제 #1
0
        public async Task RunAsync(ScenarioExecutionContext context)
        {
            await BeforeExecuteAsync(context);

            var stopwatch = Stopwatch.StartNew();

            try
            {
                await ExecuteAsync(context);

                SuccessCount++;

                LastExecutionDuration = stopwatch.Elapsed.TotalMilliseconds;

                TotalExecutionDuration += LastExecutionDuration;

                if (MinExecutionDuration > LastExecutionDuration)
                {
                    MinExecutionDuration = LastExecutionDuration;
                }

                if (MaxExecutionDuration < LastExecutionDuration)
                {
                    MaxExecutionDuration = LastExecutionDuration;
                }
            }
            catch (Exception ex)
            {
                FailCount++;

                context
                .ServiceProvider
                .GetService <ILogger <ScenarioStep> >()
                .LogException(ex);
            }
            finally
            {
                stopwatch.Stop();

                ExecutionCount++;
            }

            await AfterExecuteAsync(context);
        }
예제 #2
0
 protected virtual Task AfterExecuteAsync(ScenarioExecutionContext context)
 {
     return(Task.CompletedTask);
 }
예제 #3
0
 protected abstract Task ExecuteAsync(ScenarioExecutionContext context);
예제 #4
0
 protected override Task ExecuteAsync(ScenarioExecutionContext context)
 {
     return(Task.Delay(Duration));
 }
예제 #5
0
 protected Scenario(IServiceProvider serviceProvider)
 {
     ExecutionContext = new ScenarioExecutionContext(serviceProvider);
     Steps            = new List <ScenarioStep>();
 }