Beispiel #1
0
        public void Should_include_examples_when_converting_to_string()
        {
            var feature  = new Feature("featureTitle", "", "source", 1);
            var scenario = new Scenario("scenarioTitle", "source", feature, 3);

            scenario.AddStep(new StringStep("Given", "a [foo]", "source, 4"));
            scenario.AddStep(new StringStep("And", "[bar]", "source, 5"));
            var columnNames = new ExampleColumns {
                new ExampleColumn("foo"), new ExampleColumn("bar")
            };

            scenario.AddExamples(new[]
            {
                new Example(columnNames, new Dictionary <string, string> {
                    { "foo", "1" }, { "bar", "2" }
                }),
                new Example(columnNames, new Dictionary <string, string> {
                    { "foo", "11" }, { "bar", "22" }
                })
            });
            var    scenarioAsString = scenario.ToString();
            string expected         = string.Format("Scenario: scenarioTitle{0}  Given a [foo]{0}  And [bar]{0}", Environment.NewLine);

            expected += "Examples:" + Environment.NewLine +
                        "     | foo | bar |" + Environment.NewLine +
                        "     | 1 | 2 |" + Environment.NewLine +
                        "     | 11 | 22 |";
            Assert.AreEqual(expected, scenarioAsString);
        }
Beispiel #2
0
        private void ExtractExamplesFromTable(IList <IList <Token> > table)
        {
            if (!listenToParsedTable)
            {
                return;
            }

            var columns        = table.First().Select(token => new ExampleColumn(token.Content)).ToList();
            var exampleColumns = new ExampleColumns(columns);

            foreach (var list in table.Skip(1))
            {
                var example = list.Select(token => token.Content);
                var row     = new Dictionary <string, string>();

                for (int i = 0; i < example.Count(); i++)
                {
                    row.Add(exampleColumns[i].Name.ToLower(), example.ElementAt(i));
                }

                scenario.AddExamples(new List <Example> {
                    new Example(exampleColumns, row)
                });
            }
            listenToParsedTable = false;
        }
Beispiel #3
0
 public void Should_include_examples_when_converting_to_string()
 {
     var feature = new Feature("featureTitle", "", "source", 1);
     var scenario = new Scenario("scenarioTitle", "source", feature, 3);
     scenario.AddStep(new StringStep("Given a [foo]", "source, 4"));
     scenario.AddStep(new StringStep("And [bar]", "source, 5"));
     var columnNames = new ExampleColumns { new ExampleColumn("foo"), new ExampleColumn("bar") };
     scenario.AddExamples(new[]
                              {
                                new Example(columnNames, new Dictionary<string, string>{ {"foo", "1"}, {"bar", "2"}}),
                                new Example(columnNames, new Dictionary<string, string>{ {"foo", "11"}, {"bar", "22"}})
                              });
     var scenarioAsString = scenario.ToString();
     string expected = string.Format("Scenario: scenarioTitle{0}  Given a [foo]{0}  And [bar]{0}", Environment.NewLine);
     expected += "Examples:" + Environment.NewLine +
                 "     | foo | bar |" + Environment.NewLine +
                 "     | 1 | 2 |" + Environment.NewLine +
                 "     | 11 | 22 |";
     Assert.AreEqual(expected, scenarioAsString);
 }