public void DestroyAllActiveExecutionContexts(Scenario scenario)
 {
     foreach (ActiveScenarioExecutionContext source in _activeExecutionContexts
         .Where(x => x.Scenario.ScenarioId == scenario.ScenarioId))
     {
         source.ExecutionContext.Close();                
     }
     _activeExecutionContexts.Clear();
 }
 public ScenarioContext Create(Scenario scenario)
 {
     return new ScenarioContext(scenario, new Dictionary<string, string>
                                          {
                                              {"scenario_id", scenario.ScenarioId.ToString()},
                                              {"unique_string", _uniqueValueGenerator.GetString()},
                                              {"unique_number", _uniqueValueGenerator.GetNumber().ToString()}
                                          });
 }
        public IExecutionContext Create(Scenario scenario, Step step)
        {
            ActiveScenarioExecutionContext activeExecutionContext =
                _activeExecutionContexts.FirstOrDefault(
                    x => x.Scenario.ScenarioId == scenario.ScenarioId && GenericTypeMatchesStep(x.ExecutionContext, step));

            if (activeExecutionContext != null) return activeExecutionContext.ExecutionContext;

            IExecutionContextCreator executionContextCreator =
                _executionContextCreators.FirstOrDefault(x => x.CanCreate(step));
            if (executionContextCreator == null)
                throw new Exception(string.Format("There are no execution context creators available to handle the step '{0}'.",
                    step.GetType().Name));

            IExecutionContext executionContext = executionContextCreator.Create();
            _activeExecutionContexts.Add(new ActiveScenarioExecutionContext(scenario, executionContext));
            return executionContext;
        }
예제 #4
0
 public void Run(Scenario scenario)
 {
     _scenarioContext = _scenarioContextFactory.Create(scenario);
     scenario.ApplyContext(_scenarioContext);
     try
     {
         _progressReporter.Report(new ScenarioStartedReport(scenario.ScenarioId));
         foreach (Criterion criterion in scenario.Criteria.OrderBy(x => x.Priority))
         {
             _criterionRunner.Run(criterion, _scenarioContext, _executionContextFactory);
         }
         _progressReporter.Report(new ScenarioStoppedReport(scenario.ScenarioId));
     }
     catch (Exception ex)
     {
         _logger.LogException(ex);
         throw;
     }
     finally
     {
         _executionContextFactory.DestroyAllActiveExecutionContexts(scenario);
     }
 }
예제 #5
0
 public void Run(Scenario scenario)
 {
     _scenariosRun.Add(scenario);
 }
 public void DestroyAllActiveExecutionContexts(Scenario scenario)
 {
     _executionContext.Close();
     _browserClosed = true;
 }
 public IExecutionContext Create(Scenario scenario, Step step)
 {
     return _executionContext;
 }
 public ActiveScenarioExecutionContext(Scenario scenario, IExecutionContext executionContext)
 {
     Scenario = scenario;
     ExecutionContext = executionContext;
 }
예제 #9
0
 public ScenarioContext(Scenario scenario, IDictionary<string, string> tokenDictionary = null)
 {
     _tokenDictionary = tokenDictionary ?? new Dictionary<string, string>();
     Scenario = scenario;
     _responsePayloads = new Dictionary<string, string>();
 }
 public ScenarioContext Create(Scenario scenario)
 {
     return _scenarioContext;
 }