Esempio n. 1
0
        public void Execute(Scenario scenario, IEnumerable <IStep> steps)
        {
            _progressNotifier.NotifyScenarioStart(scenario.Name, scenario.Label);
            var stepsToExecute = PrepareSteps(scenario, steps);

            var watch             = new Stopwatch();
            var scenarioStartTime = DateTimeOffset.UtcNow;

            try
            {
                ExecutionContext.Instance = new ExecutionContext(_progressNotifier, stepsToExecute.Length);
                watch.Start();
                ExecuteSteps(stepsToExecute);
            }
            finally
            {
                watch.Stop();
                ExecutionContext.Instance = null;
                var result = new ScenarioResult(scenario.Name, stepsToExecute.Select(s => s.GetResult()), scenario.Label, scenario.Categories)
                             .SetExecutionStart(scenarioStartTime)
                             .SetExecutionTime(watch.Elapsed);

                if (ScenarioExecuted != null)
                {
                    ScenarioExecuted.Invoke(result);
                }

                _progressNotifier.NotifyScenarioFinished(result);
            }
        }
Esempio n. 2
0
        public int Execute(CancellationTokenSource cancel = null)
        {
            int res = ExecutionEngine(cancel);

            ScenarioExecuted?.Invoke(this, new ScenarioEventArgs(res));
            return(res);
        }
Esempio n. 3
0
        public Task ExecuteAsync(ScenarioInfo scenario, Func <ExtendableExecutor, object, RunnableStep[]> stepsProvider, Func <object> contextProvider, IScenarioProgressNotifier progressNotifier)
        {
            var runnableScenario = new RunnableScenario(scenario, stepsProvider, contextProvider, progressNotifier, _extendableExecutor);

            try
            {
                return(runnableScenario.RunAsync());
            }
            finally
            {
                ScenarioExecuted?.Invoke(runnableScenario.Result);
            }
        }
Esempio n. 4
0
        public Task ExecuteAsync(ScenarioInfo scenario, Func <DecoratingExecutor, object, RunnableStep[]> stepsProvider, IContextProvider contextProvider, IScenarioProgressNotifier progressNotifier, IEnumerable <IScenarioDecorator> scenarioDecorators, ExceptionProcessor exceptionProcessor)
        {
            var runnableScenario = new RunnableScenario(scenario, stepsProvider, contextProvider, progressNotifier, _decoratingExecutor, scenarioDecorators, exceptionProcessor);

            try
            {
                return(runnableScenario.RunAsync());
            }
            finally
            {
                ScenarioExecuted?.Invoke(runnableScenario.Result);
            }
        }
Esempio n. 5
0
        private IStep[] PrepareSteps(Scenario scenario, IEnumerable <IStep> steps)
        {
            try
            {
                return(steps.ToArray());
            }
            catch (Exception e)
            {
                var result = new ScenarioResult(scenario.Name, new IStepResult[0], scenario.Label, scenario.Categories)
                             .SetFailureStatus(e);

                if (ScenarioExecuted != null)
                {
                    ScenarioExecuted.Invoke(result);
                }

                _progressNotifier.NotifyScenarioFinished(result);
                throw;
            }
        }