Ejemplo n.º 1
0
        public void Format(Body body, Step step)
        {
            // HACK - We need to generate a custom paragraph here because 2 Run objects are needed to allow for the bolded keyword
            var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId {Val = "Normal"}));
            paragraph.Append(new Run(new RunProperties(new Bold()), new Text(step.NativeKeyword)));
            var nameText = new Text {Space = SpaceProcessingModeValues.Preserve};
            nameText.Text = " " + step.Name;
            paragraph.Append(new Run(nameText));
            body.Append(paragraph);

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                string[] lines = step.DocStringArgument.Split(new[] {Environment.NewLine},
                                                              StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    body.GenerateParagraph(line, "Quote");
                }
            }

            if (step.TableArgument != null)
            {
                this.wordTableFormatter.Format(body, step.TableArgument);
            }
        }
Ejemplo n.º 2
0
        public void Multiline_strings_are_formatted_as_list_items_with_pre_elements_formatted_as_code_internal()
        {
            var step = new Step
                           {
                               Keyword = Keyword.Given,
                               NativeKeyword = "Given ",
                               Name = "a simple step",
                               TableArgument = null,
                               DocStringArgument = "this is a\nmultiline table\nargument",
                           };

            var formatter = Container.Resolve<HtmlStepFormatter>();
            XElement actual = formatter.Format(step);

            XNamespace xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml");
            var expected = new XElement(xmlns + "li",
                                        new XAttribute("class", "step"),
                                        new XElement(xmlns + "span", new XAttribute("class", "keyword"),
                                                     EXPECTED_GIVEN_HTML),
                                        new XText("a simple step"),
                                        new XElement(xmlns + "div",
                                                     new XAttribute("class", "pre"),
                                                     new XElement(xmlns + "pre",
                                                                  new XElement(xmlns + "code",
                                                                               new XAttribute("class", "no-highlight"),
                                                                               new XText(
                                                                                   "this is a\nmultiline table\nargument")
                                                                      )
                                                         )
                                            )
                );

            expected.ShouldDeepEquals(actual);
        }
Ejemplo n.º 3
0
 public static Paragraph GenerateStepParagraph(Step step)
 {
     // HACK - We need to generate a custom paragraph here because 2 Run objects are needed to allow for the bolded keyword
     var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Normal" }));
     paragraph.Append(new Run(new RunProperties(new Bold()), new Text(step.NativeKeyword)));
     var nameText = new Text { Space = SpaceProcessingModeValues.Preserve };
     nameText.Text = " " + step.Name;
     paragraph.Append(new Run(nameText));
     return paragraph;
 }
Ejemplo n.º 4
0
        public void Format(XElement section, Step step)
        {
            section.Add(new XElement("p", new XElement("keyword", step.NativeKeyword), step.Name));

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                section.Add(new XElement("pre", step.DocStringArgument));
            }

            if (step.TableArgument != null)
            {
                this.ditaTableFormatter.Format(section, step.TableArgument);
            }
        }
        public void ThenStepAddedSuccessfully()
        {
            var excelStepFormatter = Container.Resolve<ExcelStepFormatter>();
            var step = new Step {NativeKeyword = "Given", Name = "I have some precondition"};

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int row = 5;
                excelStepFormatter.Format(worksheet, step, ref row);

                worksheet.Cell("C5").Value.ShouldEqual(step.NativeKeyword);
                worksheet.Cell("D5").Value.ShouldEqual(step.Name);
            }
        }
        public void ThenSingleScenarioOutlineWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve<ExcelScenarioOutlineFormatter>();
            var exampleTable = new Table();
            exampleTable.HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4");
            exampleTable.DataRows =
                new List<TableRow>(new[] {new TableRow("1", "2", "3", "4"), new TableRow("5", "6", "7", "8")});
            var example = new Example {Name = "Examples", Description = string.Empty, TableArgument = exampleTable};
			var examples = new List<Example>();
			examples.Add(example);
            var scenarioOutline = new ScenarioOutline
                                      {
                                          Name = "Test Feature",
                                          Description =
                                              "In order to test this feature,\nAs a developer\nI want to test this feature",
                                          Examples = examples
                                      };
            var given = new Step {NativeKeyword = "Given", Name = "a precondition"};
            var when = new Step {NativeKeyword = "When", Name = "an event occurs"};
            var then = new Step {NativeKeyword = "Then", Name = "a postcondition"};
            scenarioOutline.Steps = new List<Step>(new[] {given, when, then});

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int row = 3;
                excelScenarioFormatter.Format(worksheet, scenarioOutline, ref row);

                worksheet.Cell("B3").Value.ShouldEqual(scenarioOutline.Name);
                worksheet.Cell("C4").Value.ShouldEqual(scenarioOutline.Description);
                worksheet.Cell("B9").Value.ShouldEqual("Examples");
                worksheet.Cell("D10").Value.ShouldEqual("Var1");
                worksheet.Cell("E10").Value.ShouldEqual("Var2");
                worksheet.Cell("F10").Value.ShouldEqual("Var3");
                worksheet.Cell("G10").Value.ShouldEqual("Var4");
                worksheet.Cell("D11").Value.ShouldEqual(1.0);
                worksheet.Cell("E11").Value.ShouldEqual(2.0);
                worksheet.Cell("F11").Value.ShouldEqual(3.0);
                worksheet.Cell("G11").Value.ShouldEqual(4.0);
                worksheet.Cell("D12").Value.ShouldEqual(5.0);
                worksheet.Cell("E12").Value.ShouldEqual(6.0);
                worksheet.Cell("F12").Value.ShouldEqual(7.0);
                worksheet.Cell("G12").Value.ShouldEqual(8.0);
                row.ShouldEqual(13);
            }
        }
Ejemplo n.º 7
0
        public void Format(IXLWorksheet worksheet, Step step, ref int row)
        {
            worksheet.Cell(row, "C").Style.Font.SetBold();
            worksheet.Cell(row, "C").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
            worksheet.Cell(row, "C").Value = step.NativeKeyword;
            worksheet.Cell(row++, "D").Value = step.Name;

            if (step.TableArgument != null)
            {
                this.excelTableFormatter.Format(worksheet, step.TableArgument, ref row);
            }

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                this.excelDocumentStringFormatter.Format(worksheet, step.DocStringArgument, ref row);
            }
        }
Ejemplo n.º 8
0
        public XElement Format(Step step)
        {
            var li = new XElement(
                this.xmlns + "li",
                new XAttribute("class", "step"),
                new XElement(this.xmlns + "span", new XAttribute("class", "keyword"), step.NativeKeyword),
                step.Name);

            if (step.TableArgument != null)
            {
                li.Add(this.htmlTableFormatter.Format(step.TableArgument));
            }

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                li.Add(this.htmlMultilineStringFormatter.Format(step.DocStringArgument));
            }

            return li;
        }
Ejemplo n.º 9
0
        public void Format(Body body, Step step)
        {
            var paragraph = GenerateStepParagraph(step);
            body.Append(paragraph);

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                string[] lines = step.DocStringArgument.Split(new[] { Environment.NewLine },
                                                              StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    body.GenerateParagraph(line, "Quote");
                }
            }

            if (step.TableArgument != null)
            {
                this.wordTableFormatter.Format(body, step.TableArgument);
            }
        }
Ejemplo n.º 10
0
        public void Simple_steps_are_formatted_as_list_items()
        {
            var step = new Step
                           {
                               Keyword = Keyword.Given,
                               Name = "a simple step",
                               NativeKeyword = "Given ",
                               TableArgument = null,
                               DocStringArgument = null,
                           };

            var formatter = Container.Resolve<HtmlStepFormatter>();
            XElement actual = formatter.Format(step);

            XNamespace xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml");
            var expected = new XElement(xmlns + "li",
                                        new XAttribute("class", "step"),
                                        new XElement(xmlns + "span", new XAttribute("class", "keyword"),
                                                     EXPECTED_GIVEN_HTML),
                                        "a simple step"
                );

            expected.ShouldDeepEquals(actual);
        }
Ejemplo n.º 11
0
 public void AddStep(Step step)
 {
     this.steps.Add(step);
 }
Ejemplo n.º 12
0
 private void AddStepToElement(Step step)
 {
     if (this.featureElementState.IsBackgroundActive)
     {
         this.backgroundBuilder.AddStep(step);
     }
     else if (this.featureElementState.IsScenarioActive)
     {
         this.scenarioBuilder.AddStep(step);
     }
     else if (this.featureElementState.IsScenarioOutlineActive)
     {
         this.scenarioOutlineBuilder.AddStep(step);
     }
 }
Ejemplo n.º 13
0
        public void Steps_get_selected_Language()
        {
            var step = new Step
                           {
                               Keyword = Keyword.Given,
                               Name = "ett enkelt steg",
                               NativeKeyword = "Givet ",
                               TableArgument = null,
                               DocStringArgument = null,
                           };

            var configuration = Container.Resolve<Configuration>();
            configuration.Language = "sv";

            var formatter = Container.Resolve<HtmlStepFormatter>();
            XElement actual = formatter.Format(step);

            XNamespace xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml");
            var expected = new XElement(
                xmlns + "li",
                new XAttribute("class", "step"),
                new XElement(xmlns + "span", new XAttribute("class", "keyword"), "Givet "),
                "ett enkelt steg");

            expected.ShouldDeepEquals(actual);
        }
Ejemplo n.º 14
0
        public void Tables_are_formatted_as_list_items_with_tables_internal()
        {
            var table = new Table
                            {
                                HeaderRow = new TableRow("Column 1", "Column 2"),
                                DataRows = new List<TableRow> {new TableRow("Value 1", "Value 2")}
                            };

            var step = new Step
                           {
                               Keyword = Keyword.Given,
                               NativeKeyword = "Given ",
                               Name = "a simple step",
                               TableArgument = table,
                               DocStringArgument = null,
                           };

            var formatter = Container.Resolve<HtmlStepFormatter>();
            XElement actual = formatter.Format(step);

            XNamespace xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml");
            var expected = new XElement(xmlns + "li",
                                        new XAttribute("class", "step"),
                                        new XElement(xmlns + "span", new XAttribute("class", "keyword"),
                                                     EXPECTED_GIVEN_HTML),
                                        new XText("a simple step"),
                                        new XElement(xmlns + "div",
                                                     new XAttribute("class", "table_container"),
                                                     new XElement(xmlns + "table",
                                                                  new XAttribute("class", "datatable"),
                                                                  new XElement(xmlns + "thead",
                                                                               new XElement(xmlns + "tr",
                                                                                            new XElement(xmlns + "th",
                                                                                                         "Column 1"),
                                                                                            new XElement(xmlns + "th",
                                                                                                         "Column 2")
                                                                                   )
                                                                      ),
                                                                  new XElement(xmlns + "tbody",
                                                                               new XElement(xmlns + "tr",
                                                                                            new XElement(xmlns + "td",
                                                                                                         "Value 1"),
                                                                                            new XElement(xmlns + "td",
                                                                                                         "Value 2")
                                                                                   )
                                                                      )
                                                         )
                                            )
                );

            expected.ShouldDeepEquals(actual);
        }
        public void ThenSingleScenarioWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>();
            var scenario = new Scenario
                               {
                                   Name = "Test Feature",
                                   Description =
                                       "In order to test this feature,\nAs a developer\nI want to test this feature"
                               };
            var given = new Step {NativeKeyword = "Given", Name = "a precondition"};
            var when = new Step {NativeKeyword = "When", Name = "an event occurs"};
            var then = new Step {NativeKeyword = "Then", Name = "a postcondition"};
            scenario.Steps = new List<Step>(new[] {given, when, then});

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int row = 3;
                excelScenarioFormatter.Format(worksheet, scenario, ref row);

                worksheet.Cell("B3").Value.ShouldEqual(scenario.Name);
                worksheet.Cell("C4").Value.ShouldEqual(scenario.Description);
                row.ShouldEqual(8);
            }
        }