public IRestResponse Run(Step step, ScenarioContext context)
 {
     var apiStep = (ApiOptionsStep)step;
     var client = new RestClient(apiStep.Host);
     var restRequest = BuildRequest(apiStep);
     return client.Options(restRequest);
 }
 public IRestResponse Run(Step s, ScenarioContext context)
 {
     var step = (ApiDeleteStep) s;
     var client = new RestClient(step.Host);
     var restRequest = BuildRequest(step);
     return client.Delete(restRequest);
 }
 public void CleanUp(ScenarioContext scenarioContext, LinkedCriterion linkedCriterion)
 {
     bool isTheLastCriterion = linkedCriterion.Scenario.GetLinkedCriteria().Last() == linkedCriterion;
     if (isTheLastCriterion)
     {
         IWebDriver driver;
         Guid contextId = scenarioContext.Id;
         if (ScenarioWebDrivers.TryGetValue(contextId, out driver))
         {
             try
             {
                 driver.Close();
                 driver.Quit();
             }
             catch (Exception)
             {                        
                 //do nothing 
             }
             finally
             {
                 ScenarioWebDrivers.Remove(contextId);
             }
         }
     }
 }
 public IRestResponse Run(Step step, ScenarioContext context)
 {
     var apiPostStep = (ApiPutStep)step;
     var client = new RestClient(apiPostStep.Host);
     var restRequest = BuildRequest(apiPostStep);
     restRequest.AddBody(apiPostStep.RequestPayload);
     return client.Put(restRequest);
 }
 public bool Run(LinkedCriterion linkedCriterion, ScenarioContext scenarioContext)
 {
     PrepareStepsWithTokenReplacements(linkedCriterion, scenarioContext);
     IWebDriver webDriver = _webDriverProvider.GetForScenario(scenarioContext);
     bool runCriterion = RunCriterion(webDriver, linkedCriterion);
     _webDriverProvider.CleanUp(scenarioContext, linkedCriterion);
     return runCriterion;
 }
        public void Run(ScenarioContext context, ApiAssert apiAssert)
        {
            var assertStep = ((JavascriptAssert) apiAssert);

            string result = _valueRetriever.Retrieve(assertStep.JavascriptExpression, context.Payloads.ToArray()).ToString();
            if (result != "True")
            {
                throw new StepException(
                    string.Format("The javascript expression did not evaluate to true. Result was: {0}",
                        result));
            }
        }
 void PrepareStepsWithTokenReplacements(LinkedCriterion linkedCriterion, ScenarioContext context)
 {
     foreach (Step step in linkedCriterion.Criterion.GetSteps())
     {
         step.ReplaceTokens("%unique_string%", context.RandomString);
         step.ReplaceTokens("%unique_number%", context.RandomNumber);
         step.ReplaceTokens("%project_id%", linkedCriterion.Scenario.Story.Project.Id.ToString());
         step.ReplaceTokens("%story_id%", linkedCriterion.Scenario.Story.Id.ToString());
         step.ReplaceTokens("%scenario_id%", linkedCriterion.Scenario.Id.ToString());
         step.ReplaceTokens("%criterion_id%", linkedCriterion.Criterion.Id.ToString());
         step.ReplaceTokens("%step_id%", step.Id.ToString());
     }
 }
        public IWebDriver GetForScenario(ScenarioContext context)
        {
            IWebDriver driver;
            if (!ScenarioWebDrivers.TryGetValue(context.Id, out driver))
            {
                driver = new ChromeDriver(new ChromeOptions
                                          {

                                          });
                ScenarioWebDrivers.Add(context.Id, driver);
            }
            return driver;
        }