/// <summary> /// Converts the provided <see cref=" Gherkin.Ast.Background"/> instance into a <see cref="Augurk.Entities.Background"/> instance. /// </summary> /// <param name="background">The <see cref=" Gherkin.Ast.Background"/> instance that should be converted.</param> /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param> /// <returns>The converted <see cref="Augurk.Entities.Background"/> instance.</returns> public static Background ConvertToBackground(this Gherkin.Ast.Background background, GherkinDialect dialect) { if (background == null) { return(null); } return(new Background() { Title = background.Name, Keyword = background.Keyword, Steps = background.Steps.ConvertToSteps(dialect), Location = background.Location.ConvertToSourceLocation() }); }
public void ApplyBackground_WithBackground_PrependsBackgroundSteps() { var scenario = CreateTestScenario(); var backgroundSteps = new Gherkin.Ast.Step[] { new Gherkin.Ast.Step(null, null, "background", null) }; var background = new Gherkin.Ast.Background(null, null, null, null, backgroundSteps); var modified = scenario.ApplyBackground(background); Assert.Equal(scenario.Location, modified.Location); Assert.Equal(scenario.Keyword, modified.Keyword); Assert.Equal(scenario.Name, modified.Name); Assert.Equal(scenario.Description, modified.Description); Assert.Equal(2, modified.Steps.Count()); Assert.Equal("background", modified.Steps.ElementAt(0).Text); Assert.Equal("step", modified.Steps.ElementAt(1).Text); }