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;
        }
 public bool CanCreate(Step step)
 {
     return step is ApiStep;
 }
 public IExecutionContext Create(Scenario scenario, Step step)
 {
     return _executionContext;
 }
 bool GenericTypeMatchesStep(object executionContext, Step step)
 {
     var genericTypeArgs = executionContext.GetType().GetInterfaces().SelectMany(x => x.GenericTypeArguments);
     bool hasCompatibleGenericArg = genericTypeArgs.Any(x => x.IsInstanceOfType(step));
     return hasCompatibleGenericArg;
 }
 public bool CanCreate(Step step)
 {
     return step is ApiAssert;
 }
示例#6
0
 public bool CanCreate(Step step)
 {
     return step is BrowserStep;
 }
 public bool CanCreate(Step step)
 {
     var canCreate = step is BrowserStep;
     return canCreate;
 }