public void ExtractScenario_Extracts_Scenario_With_Background() { //arrange. var scenarioName = "some scenario name 123"; var featureInstance = new FeatureWithMatchingScenarioStepsToExtract(); var sut = FeatureClass.FromFeatureInstance(featureInstance); var gherkinDocument = CreateGherkinDocument(scenarioName, new string[] { "Given " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep1Text.Replace(@"(\d+)", "12", StringComparison.InvariantCultureIgnoreCase), "And " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep2Text.Replace(@"(\d+)", "15", StringComparison.InvariantCultureIgnoreCase), "When " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep3Text, "Then " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep4Text.Replace(@"(\d+)", "27", StringComparison.InvariantCultureIgnoreCase) }, null, new string[] { "Given a background step" }); //act. var scenario = sut.ExtractScenario( gherkinDocument.Feature.Children.OfType <Gherkin.Ast.Scenario>().First(), gherkinDocument.Feature.Children.OfType <Gherkin.Ast.Background>().First()); //assert. Assert.NotNull(scenario); }
public void FromFeatureInstance_DoesNotAllow_AsyncVoid_Steps() { var featureInstance = new FeatureWithAsyncVoidStep(); //act / assert. Assert.Throws <InvalidOperationException>(() => FeatureClass.FromFeatureInstance(featureInstance)); }
public void FromFeatureInstance_Creates_FeatureClass_With_FilePath_From_Attribute() { //arrange. var featureInstance = new FeatureWithFilePath(); //act. var sut = FeatureClass.FromFeatureInstance(featureInstance); //assert. Assert.NotNull(sut); Assert.Equal(FeatureWithFilePath.PathFor_FeatureWithFilePath, sut.FeatureFilePath); }
public void FromFeatureInstance_Creates_FeatureClass_With_Default_FilePath_If_No_Attribute() { //arrange. var featureInstance = new FeatureWithoutFilePath(); //act. var sut = FeatureClass.FromFeatureInstance(featureInstance); //assert. Assert.NotNull(sut); Assert.Equal($"{nameof(FeatureWithoutFilePath)}.feature", sut.FeatureFilePath); }
public void ExtractScenario_Extracts_Steps_With_Multiple_Patterns() { //arrange. var sut = FeatureClass.FromFeatureInstance(new FeatureWithMultipleStepPatterns()); //act. var scenario = sut.ExtractScenario(CreateGherkinDocument("scenario 123", new string[] { "Given something else" }).Feature.Children.OfType <Gherkin.Ast.Scenario>().First()); //assert. Assert.NotNull(scenario); }
public void ExtractScenario_Extracts_Scenario() { //arrange. var scenarioName = "some scenario name 123"; var featureInstance = new FeatureWithMatchingScenarioStepsToExtract(); var sut = FeatureClass.FromFeatureInstance(featureInstance); //act. var scenario = sut.ExtractScenario(scenarioName, new FeatureFile(CreateGherkinDocument(scenarioName, "Given " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep1Text.Replace(@"(\d+)", "12", StringComparison.InvariantCultureIgnoreCase), "And " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep2Text.Replace(@"(\d+)", "15", StringComparison.InvariantCultureIgnoreCase), "When " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep3Text, "Then " + FeatureWithMatchingScenarioStepsToExtract.ScenarioStep4Text.Replace(@"(\d+)", "27", StringComparison.InvariantCultureIgnoreCase) ))); //assert. Assert.NotNull(scenario); }
public void ExtractScnario_Extracts_Scenario_With_DataTable() { //arrange. var scenarioName = "scenario213"; var featureInstance = new FeatureWithDataTableScenarioStep(); var sut = FeatureClass.FromFeatureInstance(featureInstance); var featureFile = new FeatureFile(CreateGherkinDocument(scenarioName, "When " + FeatureWithDataTableScenarioStep.Steptext + Environment.NewLine + @" | First argument | Second argument | Result | | 1 | 2 | 3| | a | b | c | " )); //act. var scenario = sut.ExtractScenario(scenarioName, featureFile); //assert. Assert.NotNull(scenario); }
public void ExtractScnario_Extracts_Scenario_With_DataTable() { //arrange. var scenarioName = "scenario213"; var featureInstance = new FeatureWithDataTableScenarioStep(); var sut = FeatureClass.FromFeatureInstance(featureInstance); var gherknScenario = CreateGherkinDocument(scenarioName, new string[] { "When " + FeatureWithDataTableScenarioStep.Steptext }, new Gherkin.Ast.DataTable(new Gherkin.Ast.TableRow[] { new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "First argument"), new Gherkin.Ast.TableCell(null, "Second argument"), new Gherkin.Ast.TableCell(null, "Result"), }), new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "1"), new Gherkin.Ast.TableCell(null, "2"), new Gherkin.Ast.TableCell(null, "3"), }), new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "a"), new Gherkin.Ast.TableCell(null, "b"), new Gherkin.Ast.TableCell(null, "c"), }) })).Feature.Children.First() as Gherkin.Ast.Scenario; //act. var scenario = sut.ExtractScenario(gherknScenario); //assert. Assert.NotNull(scenario); }
public void ExtractScenario_Extracts_Scenario_With_DocString() { //arrange. var featureInstance = new FeatureWithDocStringScenarioStep(); var sut = FeatureClass.FromFeatureInstance(featureInstance); var scenarioName = "scenario-121kh2"; var docStringContent = @"some content +++ with multi lines --- in it"; var gherkinScenario = CreateGherkinDocument(scenarioName, new string[] { "Given " + FeatureWithDocStringScenarioStep.StepWithDocStringText }, new Gherkin.Ast.DocString(null, null, docStringContent)) .Feature.Children.First() as Gherkin.Ast.Scenario; //act. var scenario = sut.ExtractScenario(gherkinScenario); //assert. Assert.NotNull(scenario); }
public void ExtractScenario_Extracts_Scenario_With_DocString() { //arrange. var featureInstance = new FeatureWithDocStringScenarioStep(); var sut = FeatureClass.FromFeatureInstance(featureInstance); var scenarioName = "scenario-121kh2"; var docStringContent = @"some content +++ with multi lines --- in it"; var featureFile = new FeatureFile(CreateGherkinDocument(scenarioName, "Given " + FeatureWithDocStringScenarioStep.StepWithDocStringText + @" " + @""""""" " + docStringContent + @" """"""")); //act. var scenario = sut.ExtractScenario(scenarioName, featureFile); //assert. Assert.NotNull(scenario); }