示例#1
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 = Kernel.Get<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);
        }
示例#2
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)
            {
                wordTableFormatter.Format(body, step.TableArgument);
            }
        }
        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 = Kernel.Get<Configuration>();
            configuration.Language = "sv";

            var formatter = Kernel.Get<HtmlStepFormatter>();
            var actual = formatter.Format(step);

            var 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");

            AssertDeepEqualNodes(expected, actual);
        }
示例#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);
            }
        }
示例#5
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);
     }
 }
示例#6
0
        public void ThenStepAddedSuccessfully()
        {
            var excelStepFormatter = Kernel.Get<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);
            }
        }
示例#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)
            {
                excelTableFormatter.Format(worksheet, step.TableArgument, ref row);
            }

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                excelDocumentStringFormatter.Format(worksheet, step.DocStringArgument, ref row);
            }
        }
        public void ThenSingleScenarioOutlineWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Kernel.Get<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 scenarioOutline = new ScenarioOutline
                                      {
                                          Name = "Test Feature",
                                          Description =
                                              "In order to test this feature,\nAs a developer\nI want to test this feature",
                                          Example = example
                                      };
            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);
            }
        }
示例#9
0
        public XElement Format(Step step)
        {
            var li =  new XElement(xmlns + "li",
                          new XAttribute("class", "step"),
                          new XElement(xmlns + "span", new XAttribute("class", "keyword"), step.Keyword + " "),
                          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;
        }
示例#10
0
        public void Simple_steps_are_formatted_as_list_items()
        {
            var step = new Step
            {
                Keyword = Keyword.Given,
                Name = "a simple step",
                TableArgument = null,
                DocStringArgument = null,
            };

            var formatter = Kernel.Get<HtmlStepFormatter>();
            var actual = formatter.Format(step);

            var 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"), "Given"),
                               "a simple step"
                           );

            Assert.IsTrue(XElement.DeepEquals(expected, actual));
        }
示例#11
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 = Kernel.Get<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);
        }
示例#12
0
 public void AddStep(Step step)
 {
     this.steps.Add(step);
 }
示例#13
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 = Kernel.Get<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);
        }
示例#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,
                Name = "a simple step",
                TableArgument = table,
                DocStringArgument = null,
            };

            var formatter = Kernel.Get<HtmlStepFormatter>();
            var actual = formatter.Format(step);

            var 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"), "Given"),
                               new XText("a simple step"),
                               new XElement(xmlns + "table",
                                   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")
                                       )
                                   )
                               )
                           );

            Assert.IsTrue(XElement.DeepEquals(expected, actual));
        }
示例#15
0
 public void AddStep(Step step)
 {
     steps.Add(step);
 }