public BackgroundBuilder(IGherkinBlock item) { this.result = new FixtureBackground(FixtureStep.Create(GherkinKeyword.Background, item.Name)); this.result.AddComments(item.Gherkin); this.result.AddChild(Steps(GherkinStep.Given, item)); this.result.AddChild(Steps(GherkinStep.When, item)); }
public FixtureBuilder(IGherkinFeature gherkin, ISpockOptions options) { this.gherkin = gherkin; this.options = options; this.fixtureInvariants = new FixtureInvariants(gherkin, options); var summary = new List <string> { "Feature Id: " + this.fixtureInvariants.FeatureId, gherkin.Name, gherkin.Description }; if (gherkin.Background != null) { summary.AddRange(gherkin.Background.Gherkin); } var disabled = gherkin.Comments.DisabledScenarios("<item>", "</item>").ToArray(); if (disabled.Any()) { const string header = "The following Scenario Ids (Test Step Id's) have been disabled from this fixture. Please review " + "the original test cases XML file to see if the test scenario was valid, and if " + "so, update the Gherkin .feature file to reflect the test case. Then regenerate " + "this test fixture to include the new scenario."; var builder = new StringBuilder(); builder.Append(header); builder.Append("<list type=\"bullet\">"); foreach (var d in disabled) { builder.Append(d); } builder.Append("</list>"); summary.Add(builder.ToString()); } this.comments.AddRange(CodeGeneration.ToXmlSummary(summary.ToArray(), false)); this.comments.AddRange(CodeGeneration.ToXmlRemarks(gherkin.Gherkin, new[] { "example", "code language=\"none\" title=\"Gherkin\"" })); this.feature = FixtureStep.Create(GherkinKeyword.Feature, gherkin.Description); if (gherkin.Background == null) { return; } this.background = new BackgroundBuilder(gherkin.Background).Build(); this.feature.AddBackground(this.background); }
public static IFixtureStep Steps(GherkinStep step, IGherkinBlock item) { var parent = item.Steps[step]; if (parent == null) { return(null); } var result = FixtureStep.Create(parent); foreach (var child in item.Steps.Parent(parent.Step.Syntax.Block())) { result.AddChild(FixtureStep.Create(child)); } return(result); }