public async Task ExecuteScenarioAsync(Feature featureInstance, string scenarioName) { if (featureInstance == null) { throw new ArgumentNullException(nameof(featureInstance)); } if (string.IsNullOrWhiteSpace(scenarioName)) { throw new ArgumentNullException(nameof(scenarioName)); } var featureClass = FeatureClass.FromFeatureInstance(featureInstance); var featureFile = _featureFileRepository.GetByFilePath(featureClass.FeatureFilePath); var gherkinScenario = featureFile.GetScenario(scenarioName); if (gherkinScenario == null) { throw new InvalidOperationException($"Cannot find scenario `{scenarioName}`."); } var gherkinBackground = featureFile.GetBackground(); var scenario = featureClass.ExtractScenario(gherkinScenario, gherkinBackground); await scenario.ExecuteAsync(featureInstance, new ScenarioOutput(featureInstance.InternalOutput)); }
public async Task ExecuteScenarioOutlineAsync( Feature featureInstance, string scenarioOutlineName, string exampleName, int exampleRowIndex) { if (featureInstance == null) { throw new ArgumentNullException(nameof(featureInstance)); } if (string.IsNullOrWhiteSpace(scenarioOutlineName)) { throw new ArgumentNullException(nameof(scenarioOutlineName)); } if (exampleRowIndex < 0) { throw new ArgumentException($"`{nameof(exampleRowIndex)}` must be positive", nameof(exampleRowIndex)); } var featureClass = FeatureClass.FromFeatureInstance(featureInstance); var featureFile = _featureFileRepository.GetByFilePath(featureClass.FeatureFilePath); var gherkinScenarioOutline = featureFile.GetScenarioOutline(scenarioOutlineName); if (gherkinScenarioOutline == null) { throw new InvalidOperationException($"Cannot find scenario outline `{scenarioOutlineName}`."); } var gherkinScenario = gherkinScenarioOutline.ApplyExampleRow(exampleName, exampleRowIndex); var gherkinBackground = featureFile.GetBackground(); var scenario = featureClass.ExtractScenario(gherkinScenario, gherkinBackground); await scenario.ExecuteAsync(featureInstance, new ScenarioOutput(featureInstance.InternalOutput)); }