Esempio n. 1
0
 private static Gherkin.Ast.GherkinDocument CreateGherkinDocument(
     string scenario,
     string[] steps,
     Gherkin.Ast.StepArgument stepArgument = null)
 {
     return(new Gherkin.Ast.GherkinDocument(
                new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]
     {
         new Gherkin.Ast.Scenario(
             new Gherkin.Ast.Tag[0],
             null,
             null,
             scenario,
             null,
             steps.Select(s =>
         {
             var spaceIndex = s.IndexOf(' ');
             return new Gherkin.Ast.Step(
                 null,
                 s.Substring(0, spaceIndex).Trim(),
                 s.Substring(spaceIndex).Trim(),
                 stepArgument);
         }).ToArray())
     }),
                new Gherkin.Ast.Comment[0]));
 }
 private static Gherkin.Ast.GherkinDocument CreateGherkinDocument(
     string outlineName,
     Gherkin.Ast.StepArgument stepArgument = null)
 {
     return(new Gherkin.Ast.GherkinDocument(
                new GherkinFeatureBuilder()
                .WithScenarioOutline(outlineName, sb => sb
                                     .Given("I chose <a> as first number", stepArgument)
                                     .And("I chose <b> as second number", stepArgument)
                                     .When("I press add", stepArgument)
                                     .Then("the result should be <sum> on the screen", stepArgument),
                                     eb => eb
                                     .WithExampleHeadings("a", "b", "sum")
                                     .WithExamples("", db => db
                                                   .WithData(0, 1, 1)
                                                   .WithData(1, 9, 10))
                                     .WithExamples("of bigger numbers", db => db
                                                   .WithData(99, 1, 100)
                                                   .WithData(100, 200, 300))
                                     .WithExamples("of large numbers", db => db
                                                   .WithData(999, 1, 1000)
                                                   .WithData(9999, 1, 10000)))
                .Build(),
                new Gherkin.Ast.Comment[0]));
 }
Esempio n. 3
0
        private static Gherkin.Ast.GherkinDocument CreateGherkinDocument(
            string scenario,
            string[] steps,
            Gherkin.Ast.StepArgument stepArgument = null,
            string[] backgroundSteps = null)
        {
            var definitions = new List <global::Gherkin.Ast.ScenarioDefinition>
            {
                new Gherkin.Ast.Scenario(
                    new Gherkin.Ast.Tag[0],
                    null,
                    null,
                    scenario,
                    null,
                    steps.Select(s =>
                {
                    var spaceIndex = s.IndexOf(' ');
                    return(new Gherkin.Ast.Step(
                               null,
                               s.Substring(0, spaceIndex).Trim(),
                               s.Substring(spaceIndex).Trim(),
                               stepArgument));
                }).ToArray())
            };

            if (backgroundSteps != null)
            {
                definitions.Add(
                    new Gherkin.Ast.Background(
                        null,
                        null,
                        "background",
                        null,
                        backgroundSteps.Select(s =>
                {
                    var spaceIndex = s.IndexOf(' ');
                    return(new Gherkin.Ast.Step(
                               null,
                               s.Substring(0, spaceIndex).Trim(),
                               s.Substring(spaceIndex).Trim(),
                               stepArgument));
                }).ToArray()));
            }

            return(new Gherkin.Ast.GherkinDocument(
                       new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, definitions.ToArray()),
                       new Gherkin.Ast.Comment[0]));
        }
        /// <summary>
        /// Converts the provided <see cref="Gherkin.Ast.StepArgument"/> instance into a <see cref="Augurk.Entities.Table"/> instance.
        /// </summary>
        /// <param name="table">The <see cref="Gherkin.Ast.StepArgument"/> instance that should be converted.</param>
        /// <returns>The converted <see cref="Augurk.Entities.Table"/> instanc, or <c>null</c> if the provided <paramref name="argument"/> is not a <see cref="Gherkin.Ast.DataTable"/>.</returns>
        public static Table ConvertToTable(this Gherkin.Ast.StepArgument argument)
        {
            Gherkin.Ast.DataTable table = argument as Gherkin.Ast.DataTable;
            if (table == null)
            {
                return(null);
            }

            return(new Table
            {
                Columns = table.Rows.FirstOrDefault()?.Cells.Select(cell => cell.Value).ToArray(),
                // Skip the first row as those are the headers
                Rows = table.Rows.Skip(1).Select(row => row.Cells.Select(cell => cell.Value).ToArray()).ToArray(),
                Location = table.Location.ConvertToSourceLocation()
            });
        }
 private static Gherkin.Ast.GherkinDocument CreateGherkinDocumentWithScenario(
     string scenario,
     Gherkin.Ast.StepArgument stepArgument = null)
 {
     return(new Gherkin.Ast.GherkinDocument(
                new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]
     {
         new Gherkin.Ast.Scenario(
             new Gherkin.Ast.Tag[0],
             null,
             null,
             scenario,
             null,
             new Gherkin.Ast.Step[] { })
     }),
                new Gherkin.Ast.Comment[0]));
 }
 public static Gherkin.Ast.GherkinDocument CreateGherkinDocument(
     string outlineName,
     Gherkin.Ast.StepArgument stepArgument = null)
 {
     return(new Gherkin.Ast.GherkinDocument(
                new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]
     {
         new Gherkin.Ast.ScenarioOutline(
             new Gherkin.Ast.Tag[0],
             null,
             null,
             outlineName,
             null,
             new Gherkin.Ast.Step[]
         {
             new Gherkin.Ast.Step(null, "Given", Steptext, stepArgument)
         },
             new Gherkin.Ast.Examples[]
         {
             new Gherkin.Ast.Examples(null, null, null, "", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "0"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "1")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "9"),
                     new Gherkin.Ast.TableCell(null, "10")
                 })
             }),
             new Gherkin.Ast.Examples(null, null, null, "of bigger numbers", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "99"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "100")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "100"),
                     new Gherkin.Ast.TableCell(null, "200"),
                     new Gherkin.Ast.TableCell(null, "300")
                 })
             }),
             new Gherkin.Ast.Examples(null, null, null, "of large numbers", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "999"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "1000")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "9999"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "10000")
                 })
             })
         })
     }),
                new Gherkin.Ast.Comment[0]));
 }
 private static Gherkin.Ast.GherkinDocument CreateGherkinDocument(
     string outlineName,
     Gherkin.Ast.StepArgument stepArgument = null)
 {
     return(new Gherkin.Ast.GherkinDocument(
                new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]
     {
         new Gherkin.Ast.ScenarioOutline(
             new Gherkin.Ast.Tag[0],
             null,
             null,
             outlineName,
             null,
             new Gherkin.Ast.Step[]
         {
             new Gherkin.Ast.Step(null, "Given", "I chose <a> as first number", stepArgument),
             new Gherkin.Ast.Step(null, "And", "I chose <b> as second number", stepArgument),
             new Gherkin.Ast.Step(null, "When", "I press add", stepArgument),
             new Gherkin.Ast.Step(null, "Then", "the result should be <sum> on the screen", stepArgument)
         },
             new Gherkin.Ast.Examples[]
         {
             new Gherkin.Ast.Examples(null, null, null, "", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "0"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "1")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "9"),
                     new Gherkin.Ast.TableCell(null, "10")
                 })
             }),
             new Gherkin.Ast.Examples(null, null, null, "of bigger numbers", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "99"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "100")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "100"),
                     new Gherkin.Ast.TableCell(null, "200"),
                     new Gherkin.Ast.TableCell(null, "300")
                 })
             }),
             new Gherkin.Ast.Examples(null, null, null, "of large numbers", null,
                                      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, "sum"),
             }),
                                      new Gherkin.Ast.TableRow[]
             {
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "999"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "1000")
                 }),
                 new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[]
                 {
                     new Gherkin.Ast.TableCell(null, "9999"),
                     new Gherkin.Ast.TableCell(null, "1"),
                     new Gherkin.Ast.TableCell(null, "10000")
                 })
             })
         })
     }),
                new Gherkin.Ast.Comment[0]));
 }