diff --git a/src/Pickles/.vs/config/applicationhost.config b/src/Pickles/.vs/config/applicationhost.config index 9e44d75d3..984e93ccf 100644 --- a/src/Pickles/.vs/config/applicationhost.config +++ b/src/Pickles/.vs/config/applicationhost.config @@ -163,7 +163,7 @@ - + diff --git a/src/Pickles/Examples/Features/03ScenarioOutline/ScenarioOutline.feature b/src/Pickles/Examples/Features/03ScenarioOutline/ScenarioOutline.feature index 29d413637..730256afe 100644 --- a/src/Pickles/Examples/Features/03ScenarioOutline/ScenarioOutline.feature +++ b/src/Pickles/Examples/Features/03ScenarioOutline/ScenarioOutline.feature @@ -11,12 +11,14 @@ Scenario Outline: Add two positive numbers with many examples When I perform add Then the result should be +@small @short_test Examples: less than 100 | number 1 | number 2 | result | | 10 | 20 | 30 | | 20 | 20 | 40 | | 20 | 30 | 50 | +@big Examples: more than 100 | number 1 | number 2 | result | | 100 | 20 | 120 | diff --git a/src/Pickles/Pickles.BaseDhtmlFiles/Index.html b/src/Pickles/Pickles.BaseDhtmlFiles/Index.html index bcdb65183..a5051a721 100644 --- a/src/Pickles/Pickles.BaseDhtmlFiles/Index.html +++ b/src/Pickles/Pickles.BaseDhtmlFiles/Index.html @@ -1,4 +1,4 @@ - + @@ -146,9 +146,9 @@
- + - +

@@ -166,10 +166,10 @@

Background:

- - - - + + + +
@@ -186,11 +186,21 @@

    -
  • -
    Examples:
    -
    -
    -
  • +
  • +
    + + + + + + +
    +
    + Examples: +
    +
    +
    +

@@ -299,233 +309,233 @@ + setupSubmitSearchWhenEnterKeyPressed(); + }); + diff --git a/src/Pickles/Pickles.BaseDhtmlFiles/css/styles.css b/src/Pickles/Pickles.BaseDhtmlFiles/css/styles.css index fb8e9b801..71c474823 100644 --- a/src/Pickles/Pickles.BaseDhtmlFiles/css/styles.css +++ b/src/Pickles/Pickles.BaseDhtmlFiles/css/styles.css @@ -110,6 +110,12 @@ li.step { color: #0000FF; } +.tags { + color: #44546a; + font-style: italic; + font-weight: normal; +} + .steps table { margin-bottom: 0px; } diff --git a/src/Pickles/Pickles.BaseDhtmlFiles/js/featuresModel.js b/src/Pickles/Pickles.BaseDhtmlFiles/js/featuresModel.js index 672a0b216..d80bf4800 100644 --- a/src/Pickles/Pickles.BaseDhtmlFiles/js/featuresModel.js +++ b/src/Pickles/Pickles.BaseDhtmlFiles/js/featuresModel.js @@ -47,7 +47,8 @@ function Examples(data) { this.Name = data.Name || ''; this.Description = data.Description || ''; this.TableArgument = data.TableArgument == null ? null : new TableArgument(data.TableArgument.HeaderRow, data.TableArgument.DataRows); -} + this.Tags = data.Tags || null; + } function Background(data) { this.Name = data.Name || ''; diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAFeatureToAWorksheet.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAFeatureToAWorksheet.cs index c63ece56c..cefed1d8c 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAFeatureToAWorksheet.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAFeatureToAWorksheet.cs @@ -45,7 +45,8 @@ public void Then_feature_is_added_successfully() { Name = "Test Feature", Description = - "In order to test this feature,\nAs a developer\nI want to test this feature" + "In order to test this feature,\nAs a developer\nI want to test this feature", + Tags = { "tag1", "tag2" } }; using (var workbook = new XLWorkbook()) @@ -54,7 +55,8 @@ public void Then_feature_is_added_successfully() excelFeatureFormatter.Format(worksheet, feature); Check.That(worksheet.Cell("A1").Value).IsEqualTo(feature.Name); - Check.That(worksheet.Cell("B2").Value).IsEqualTo(feature.Description); + Check.That(worksheet.Cell("C2").Value).IsEqualTo("tag1, tag2"); + Check.That(worksheet.Cell("B3").Value).IsEqualTo(feature.Description); } } @@ -68,12 +70,14 @@ public void Then_feature_with_background_is_added_successfully() Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", + Tags = { "tag1", "tag2" } }; var background = new Scenario { Name = "Test Background Scenario", Description = - "In order to test this background,\nAs a developer\nI want to test this background" + "In order to test this background,\nAs a developer\nI want to test this background", + Tags = { "tag1", "tag2" } }; var given = new Step { NativeKeyword = "Given", Name = "a precondition" }; background.Steps = new List(new[] { given }); @@ -83,10 +87,10 @@ public void Then_feature_with_background_is_added_successfully() { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); - - Check.That(worksheet.Cell("B4").Value).IsEqualTo(background.Name); - Check.That(worksheet.Cell("C5").Value).IsEqualTo(background.Description); - Check.That(worksheet.Cell("D6").Value).IsEqualTo(given.Name); + Check.That(worksheet.Cell("B5").Value).IsEqualTo(background.Name); + Check.That(worksheet.Cell("C6").Value).IsEqualTo("tag1, tag2"); + Check.That(worksheet.Cell("C7").Value).IsEqualTo(background.Description); + Check.That(worksheet.Cell("D8").Value).IsEqualTo(given.Name); } } @@ -100,12 +104,14 @@ public void Then_feature_without_background_adds_first_scenario_on_correct_row() Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", + Tags = { "tag1", "tag2" } }; var scenario = new Scenario { Name = "Test Scenario", Description = - "In order to test this scenario,\nAs a developer\nI want to test this scenario" + "In order to test this scenario,\nAs a developer\nI want to test this scenario", + Tags = { "tag1", "tag2" } }; var given = new Step { NativeKeyword = "Given", Name = "a precondition" }; scenario.Steps = new List(new[] { given }); @@ -116,9 +122,10 @@ public void Then_feature_without_background_adds_first_scenario_on_correct_row() IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); - Check.That(worksheet.Cell("B4").Value).IsEqualTo(scenario.Name); - Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenario.Description); - Check.That(worksheet.Cell("D6").Value).IsEqualTo(given.Name); + Check.That(worksheet.Cell("B5").Value).IsEqualTo(scenario.Name); + Check.That(worksheet.Cell("C6").Value).IsEqualTo("tag1, tag2"); + Check.That(worksheet.Cell("C7").Value).IsEqualTo(scenario.Description); + Check.That(worksheet.Cell("D8").Value).IsEqualTo(given.Name); } } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioOutlineToAWorksheet.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioOutlineToAWorksheet.cs index 8aff6e66d..8bfa60599 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioOutlineToAWorksheet.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioOutlineToAWorksheet.cs @@ -53,7 +53,8 @@ public void ThenSingleScenarioOutlineAddedSuccessfully() Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", - Examples = examples + Examples = examples, + Tags = { "tag1", "tag2" } }; using (var workbook = new XLWorkbook()) @@ -63,21 +64,22 @@ public void ThenSingleScenarioOutlineAddedSuccessfully() excelScenarioFormatter.Format(worksheet, scenarioOutline, ref row); Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenarioOutline.Name); - Check.That(worksheet.Cell("C4").Value).IsEqualTo(scenarioOutline.Description); - Check.That(worksheet.Cell("B6").Value).IsEqualTo("Examples"); - Check.That(worksheet.Cell("D7").Value).IsEqualTo("Var1"); - Check.That(worksheet.Cell("E7").Value).IsEqualTo("Var2"); - Check.That(worksheet.Cell("F7").Value).IsEqualTo("Var3"); - Check.That(worksheet.Cell("G7").Value).IsEqualTo("Var4"); - Check.That(worksheet.Cell("D8").Value).IsEqualTo(1.0); - Check.That(worksheet.Cell("E8").Value).IsEqualTo(2.0); - Check.That(worksheet.Cell("F8").Value).IsEqualTo(3.0); - Check.That(worksheet.Cell("G8").Value).IsEqualTo(4.0); - Check.That(worksheet.Cell("D9").Value).IsEqualTo(5.0); - Check.That(worksheet.Cell("E9").Value).IsEqualTo(6.0); - Check.That(worksheet.Cell("F9").Value).IsEqualTo(7.0); - Check.That(worksheet.Cell("G9").Value).IsEqualTo(8.0); - Check.That(row).IsEqualTo(10); + Check.That(worksheet.Cell("C4").Value).IsEqualTo("tag1, tag2"); + Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenarioOutline.Description); + Check.That(worksheet.Cell("B7").Value).IsEqualTo("Examples"); + Check.That(worksheet.Cell("D8").Value).IsEqualTo("Var1"); + Check.That(worksheet.Cell("E8").Value).IsEqualTo("Var2"); + Check.That(worksheet.Cell("F8").Value).IsEqualTo("Var3"); + Check.That(worksheet.Cell("G8").Value).IsEqualTo("Var4"); + Check.That(worksheet.Cell("D9").Value).IsEqualTo(1.0); + Check.That(worksheet.Cell("E9").Value).IsEqualTo(2.0); + Check.That(worksheet.Cell("F9").Value).IsEqualTo(3.0); + Check.That(worksheet.Cell("G9").Value).IsEqualTo(4.0); + Check.That(worksheet.Cell("D10").Value).IsEqualTo(5.0); + Check.That(worksheet.Cell("E10").Value).IsEqualTo(6.0); + Check.That(worksheet.Cell("F10").Value).IsEqualTo(7.0); + Check.That(worksheet.Cell("G10").Value).IsEqualTo(8.0); + Check.That(row).IsEqualTo(11); } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioToAWorksheet.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioToAWorksheet.cs index 2e7962ff2..c1f5f20dc 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioToAWorksheet.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel.UnitTests/WhenAddingAScenarioToAWorksheet.cs @@ -45,7 +45,8 @@ public void ThenSingleScenarioAddedSuccessfully() { Name = "Test Feature", Description = - "In order to test this feature,\nAs a developer\nI want to test this feature" + "In order to test this feature,\nAs a developer\nI want to test this feature", + Tags = { "tag1", "tag2" } }; using (var workbook = new XLWorkbook()) @@ -55,8 +56,9 @@ public void ThenSingleScenarioAddedSuccessfully() excelScenarioFormatter.Format(worksheet, scenario, ref row); Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenario.Name); - Check.That(worksheet.Cell("C4").Value).IsEqualTo(scenario.Description); - Check.That(row).IsEqualTo(5); + Check.That(worksheet.Cell("C4").Value).IsEqualTo("tag1, tag2"); + Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenario.Description); + Check.That(row).IsEqualTo(6); } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelFeatureFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelFeatureFormatter.cs index 4b82ce2ff..1fa6a0ba3 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelFeatureFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelFeatureFormatter.cs @@ -18,6 +18,7 @@ // // -------------------------------------------------------------------------------------------------------------------- +using System; using System.Collections.Generic; using System.Reflection; using ClosedXML.Excel; @@ -52,18 +53,26 @@ public void Format(IXLWorksheet worksheet, Feature feature) worksheet.Cell("A1").Style.Font.SetBold(); worksheet.Cell("A1").Value = feature.Name; + if (feature.Tags != null && feature.Tags.Count != 0) + { + worksheet.Cell("B2").Value = "Tags:"; + worksheet.Cell("C2").Value = String.Join(", ", feature.Tags); + worksheet.Range("B2:C2").Style.Font.Italic = true; + worksheet.Range("B2:C2").Style.Font.FontColor = XLColor.DavysGrey; + } + if (feature.Description.Length <= short.MaxValue) { - worksheet.Cell("B2").Value = feature.Description; + worksheet.Cell("B3").Value = feature.Description; } else { var description = feature.Description.Substring(0, short.MaxValue); Log.Warn("The description of feature {0} was truncated because of cell size limitations in Excel.", feature.Name); - worksheet.Cell("B2").Value = description; + worksheet.Cell("B3").Value = description; } - worksheet.Cell("B2").Style.Alignment.WrapText = false; + worksheet.Cell("B3").Style.Alignment.WrapText = false; var results = this.testResults.GetFeatureResult(feature); @@ -82,7 +91,7 @@ public void Format(IXLWorksheet worksheet, Feature feature) featureElementsToRender.AddRange(feature.FeatureElements); - var row = 4; + var row = 5; foreach (var featureElement in featureElementsToRender) { var scenario = featureElement as Scenario; diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioFormatter.cs index 2b8000ee0..d546e4b2e 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioFormatter.cs @@ -46,6 +46,18 @@ public void Format(IXLWorksheet worksheet, Scenario scenario, ref int row) int originalRow = row; worksheet.Cell(row, "B").Style.Font.SetBold(); worksheet.Cell(row++, "B").Value = scenario.Name; + + if (scenario.Tags != null && scenario.Tags.Count != 0) + { + worksheet.Cell(row, "B").Value = "Tags:"; + worksheet.Cell(row, "C").Value = String.Join(", ", scenario.Tags); + worksheet.Cell(row, "B").Style.Font.Italic = true; + worksheet.Cell(row, "B").Style.Font.FontColor = XLColor.DavysGrey; + worksheet.Cell(row, "C").Style.Font.Italic = true; + worksheet.Cell(row, "C").Style.Font.FontColor = XLColor.DavysGrey; + row++; + } + worksheet.Cell(row++, "C").Value = scenario.Description; var results = this.testResults.GetScenarioResult(scenario); diff --git a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioOutlineFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioOutlineFormatter.cs index 998191251..a23e65cdc 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioOutlineFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Excel/ExcelScenarioOutlineFormatter.cs @@ -47,8 +47,22 @@ public ExcelScenarioOutlineFormatter( public void Format(IXLWorksheet worksheet, ScenarioOutline scenarioOutline, ref int row) { int originalRow = row; + worksheet.Cell(row, "B").Style.Font.SetBold(); worksheet.Cell(row++, "B").Value = scenarioOutline.Name; - worksheet.Cell(row++, "C").Value = scenarioOutline.Description; + + if (scenarioOutline.Tags != null && scenarioOutline.Tags.Count != 0) + { + worksheet.Cell(row, "B").Value = "Tags:"; + worksheet.Cell(row, "C").Value = String.Join(", ", scenarioOutline.Tags); + worksheet.Cell(row, "B").Style.Font.Italic = true; + worksheet.Cell(row, "B").Style.Font.FontColor = XLColor.DavysGrey; + worksheet.Cell(row, "C").Style.Font.Italic = true; + worksheet.Cell(row, "C").Style.Font.FontColor = XLColor.DavysGrey; + row++; + } + + if (! string.IsNullOrWhiteSpace(scenarioOutline.Description)) + worksheet.Cell(row++, "C").Value = scenarioOutline.Description; var results = this.testResults.GetScenarioOutlineResult(scenarioOutline); if (this.configuration.HasTestResults && (results != TestResult.Inconclusive)) @@ -68,7 +82,21 @@ public void Format(IXLWorksheet worksheet, ScenarioOutline scenarioOutline, ref foreach (var example in scenarioOutline.Examples) { worksheet.Cell(row++, "B").Value = "Examples"; - worksheet.Cell(row, "C").Value = example.Description; + + if (example.Tags != null && example.Tags.Count != 0) + { + worksheet.Cell(row, "C").Value = "Tags:"; + worksheet.Cell(row, "D").Value = String.Join(", ", example.Tags); + worksheet.Cell(row, "C").Style.Font.Italic = true; + worksheet.Cell(row, "C").Style.Font.FontColor = XLColor.DavysGrey; + worksheet.Cell(row, "D").Style.Font.Italic = true; + worksheet.Cell(row, "D").Style.Font.FontColor = XLColor.DavysGrey; + row++; + } + + if (! string.IsNullOrWhiteSpace(example.Description)) + worksheet.Cell(row++, "C").Value = example.Description; + this.excelTableFormatter.Format(worksheet, example.TableArgument, ref row); } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html.UnitTests/WhenFormattingScenario.cs b/src/Pickles/Pickles.DocumentationBuilders.Html.UnitTests/WhenFormattingScenario.cs index 1a0a4f8fc..2de59bd5c 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Html.UnitTests/WhenFormattingScenario.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Html.UnitTests/WhenFormattingScenario.cs @@ -58,11 +58,11 @@ public void ThenCanRenderTags() Check.That(header).HasAttribute("class", "scenario-heading"); Check.That(header.Elements().Count()).IsEqualTo(3); - Check.That(header.Elements().ElementAt(0)).IsNamed("h2"); - Check.That(header.Elements().ElementAt(1)).IsNamed("p"); + Check.That(header.Elements().ElementAt(0)).IsNamed("p"); + Check.That(header.Elements().ElementAt(1)).IsNamed("h2"); Check.That(header.Elements().ElementAt(2)).IsNamed("div"); - var tagsParagraph = header.Elements().ElementAt(1); + var tagsParagraph = header.Elements().ElementAt(0); Check.That(tagsParagraph.ToString()).IsEqualTo( @"

Tags: tag1, tag2

"); @@ -121,11 +121,11 @@ public void FeatureTagsAreAddedToScenarioTags() Check.That(header.Elements().Count()).IsEqualTo(3); - Check.That(header.Elements().ElementAt(0)).IsNamed("h2"); - Check.That(header.Elements().ElementAt(1)).IsNamed("p"); - Check.That(header.Elements().ElementAt(2)).IsNamed("div"); + Check.That(header.Elements().ElementAt(0)).IsNamed("p"); // tags + Check.That(header.Elements().ElementAt(1)).IsNamed("h2"); // title + Check.That(header.Elements().ElementAt(2)).IsNamed("div");// description - var tagsParagraph = header.Elements().ElementAt(1); + var tagsParagraph = header.Elements().ElementAt(0); Check.That(tagsParagraph.ToString()).IsEqualTo(@"

Tags: featureTag1, featureTag2, scenarioTag1, scenarioTag2

"); } @@ -157,11 +157,11 @@ public void TagsAreRenderedAlphabetically() Check.That(header.Elements().Count()).IsEqualTo(3); - Check.That(header.Elements().ElementAt(0)).IsNamed("h2"); - Check.That(header.Elements().ElementAt(1)).IsNamed("p"); + Check.That(header.Elements().ElementAt(0)).IsNamed("p"); + Check.That(header.Elements().ElementAt(1)).IsNamed("h2"); Check.That(header.Elements().ElementAt(2)).IsNamed("div"); - var tagsParagraph = header.Elements().ElementAt(1); + var tagsParagraph = header.Elements().ElementAt(0); Check.That(tagsParagraph.ToString()).IsEqualTo(@"

Tags: a, b, c, d

"); } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlFeatureFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlFeatureFormatter.cs index 95f122ba3..d48581633 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlFeatureFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlFeatureFormatter.cs @@ -54,8 +54,7 @@ public XElement Format(Feature feature) var div = new XElement( this.xmlns + "div", new XAttribute("id", "feature"), - this.htmlImageResultFormatter.Format(feature), - new XElement(this.xmlns + "h1", feature.Name)); + this.htmlImageResultFormatter.Format(feature)); var tags = RetrieveTags(feature); if (tags.Length > 0) @@ -65,6 +64,8 @@ public XElement Format(Feature feature) div.Add(paragraph); } + div.Add(new XElement(this.xmlns + "h1", feature.Name)); + div.Add(this.htmlDescriptionFormatter.Format(feature.Description)); var scenarios = new XElement(this.xmlns + "ul", new XAttribute("id", "scenarios")); diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioFormatter.cs index 48b6775f7..6b5affb49 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioFormatter.cs @@ -50,8 +50,7 @@ public XElement Format(Scenario scenario, int id) var header = new XElement( this.xmlns + "div", new XAttribute("class", "scenario-heading"), - string.IsNullOrEmpty(scenario.Slug) ? null : new XAttribute("id", scenario.Slug), - new XElement(this.xmlns + "h2", scenario.Name)); + string.IsNullOrEmpty(scenario.Slug) ? null : new XAttribute("id", scenario.Slug)); var tags = RetrieveTags(scenario); if (tags.Length > 0) @@ -61,6 +60,8 @@ public XElement Format(Scenario scenario, int id) header.Add(paragraph); } + header.Add(new XElement(this.xmlns + "h2", scenario.Name)); + header.Add(this.htmlDescriptionFormatter.Format(scenario.Description)); return new XElement( diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioOutlineFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioOutlineFormatter.cs index b1e0d6fb5..b23f4252f 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioOutlineFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Html/HtmlScenarioOutlineFormatter.cs @@ -19,6 +19,7 @@ // -------------------------------------------------------------------------------------------------------------------- using System; +using System.Collections.Generic; using System.Linq; using System.Xml.Linq; @@ -60,8 +61,8 @@ private XElement FormatHeading(ScenarioOutline scenarioOutline) var result = new XElement( this.xmlns + "div", new XAttribute("class", "scenario-heading"), - string.IsNullOrEmpty(scenarioOutline.Slug) ? null : new XAttribute("id", scenarioOutline.Slug), - new XElement(this.xmlns + "h2", scenarioOutline.Name)); + string.IsNullOrEmpty(scenarioOutline.Slug) ? null : new XAttribute("id", scenarioOutline.Slug) + ); var tags = RetrieveTags(scenarioOutline); if (tags.Length > 0) @@ -71,6 +72,8 @@ private XElement FormatHeading(ScenarioOutline scenarioOutline) result.Add(paragraph); } + result.Add(new XElement(this.xmlns + "h2", scenarioOutline.Name)); + result.Add(this.htmlDescriptionFormatter.Format(scenarioOutline.Description)); return result; @@ -120,6 +123,7 @@ private XElement FormatExamples(ScenarioOutline scenarioOutline) new XElement( this.xmlns + "div", new XAttribute("class", "examples"), + (example.Tags == null || example.Tags.Count == 0) ? null : new XElement(this.xmlns + "p", new XAttribute("class", "tags"), HtmlScenarioFormatter.CreateTagElements(example.Tags.OrderBy(t => t).ToArray(), this.xmlns)), new XElement(this.xmlns + "h3", "Examples: " + example.Name), this.htmlDescriptionFormatter.Format(example.Description), (example.TableArgument == null) ? null : this.htmlTableFormatter.Format(example.TableArgument, scenarioOutline))); diff --git a/src/Pickles/Pickles.DocumentationBuilders.Html/Resources/css/structure.css b/src/Pickles/Pickles.DocumentationBuilders.Html/Resources/css/structure.css index 2b9d2430a..392f66f3e 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Html/Resources/css/structure.css +++ b/src/Pickles/Pickles.DocumentationBuilders.Html/Resources/css/structure.css @@ -160,6 +160,9 @@ div.description ul { #feature p.tags { font-style: italic; + color: #44546a; + font-weight: normal; + margin-bottom: -20px; } /************************************************************************* @@ -245,6 +248,12 @@ a.scenario-link { color: gray; } +.tags { + font-style: italic; + color: #44546a; + font-weight: normal; +} + /************************************************************************* * Footer *************************************************************************/ diff --git a/src/Pickles/Pickles.DocumentationBuilders.Json/JsonExample.cs b/src/Pickles/Pickles.DocumentationBuilders.Json/JsonExample.cs index 08e386f22..d5da793dc 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Json/JsonExample.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Json/JsonExample.cs @@ -19,6 +19,7 @@ // -------------------------------------------------------------------------------------------------------------------- using System; +using System.Collections.Generic; namespace PicklesDoc.Pickles.DocumentationBuilders.Json { @@ -29,5 +30,7 @@ public class JsonExample public string Description { get; set; } public JsonTable TableArgument { get; set; } + + public List Tags { get; set; } } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Json/Mapper/ExampleToJsonExampleMapper.cs b/src/Pickles/Pickles.DocumentationBuilders.Json/Mapper/ExampleToJsonExampleMapper.cs index f2566fba2..90f7adcd4 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Json/Mapper/ExampleToJsonExampleMapper.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Json/Mapper/ExampleToJsonExampleMapper.cs @@ -19,7 +19,8 @@ // -------------------------------------------------------------------------------------------------------------------- using System; - +using System.Collections.Generic; +using System.Linq; using PicklesDoc.Pickles.ObjectModel; namespace PicklesDoc.Pickles.DocumentationBuilders.Json.Mapper @@ -44,7 +45,8 @@ public JsonExample Map(Example example) { Name = example.Name, Description = example.Description, - TableArgument = this.tableMapper.Map(example.TableArgument) + TableArgument = this.tableMapper.Map(example.TableArgument), + Tags = (example.Tags ?? new List()).ToList(), }; } } diff --git a/src/Pickles/Pickles.DocumentationBuilders.Word/WordFeatureFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Word/WordFeatureFormatter.cs index 7b085a304..944173f6c 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Word/WordFeatureFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Word/WordFeatureFormatter.cs @@ -19,6 +19,7 @@ // -------------------------------------------------------------------------------------------------------------------- using System; +using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Wordprocessing; using PicklesDoc.Pickles.DirectoryCrawler; using PicklesDoc.Pickles.DocumentationBuilders.Word.Extensions; @@ -74,6 +75,15 @@ public void Format(Body body, FeatureNode featureNode) } body.GenerateParagraph(feature.Name, "Heading1"); + + if ( feature.Tags.Count != 0 ) + { + var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId {Val = "Normal"})); + var tagrunProp = new RunProperties(new Italic(), new Color {ThemeColor = ThemeColorValues.Text2}) {Bold = new Bold() {Val = false}}; + paragraph.Append(new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", feature.Tags) + ")"))); + body.Append(paragraph); + } + this.wordDescriptionFormatter.Format(body, feature.Description); if (feature.Background != null) diff --git a/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioFormatter.cs index 511b7218d..8251f718a 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioFormatter.cs @@ -55,6 +55,13 @@ public void Format(Body body, Scenario scenario) } body.GenerateParagraph(scenario.Name, "Heading2"); + if (scenario.Tags.Count != 0) + { + var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Normal" })); + var tagrunProp = new RunProperties(new Italic(), new Color { ThemeColor = ThemeColorValues.Text2 }) { Bold = new Bold() { Val = false } }; + paragraph.Append(new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", scenario.Tags) + ")"))); + body.Append(paragraph); + } if (!string.IsNullOrEmpty(scenario.Description)) { body.GenerateParagraph(scenario.Description, "Normal"); diff --git a/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioOutlineFormatter.cs b/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioOutlineFormatter.cs index 3428b8a22..1d7a517bf 100644 --- a/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioOutlineFormatter.cs +++ b/src/Pickles/Pickles.DocumentationBuilders.Word/WordScenarioOutlineFormatter.cs @@ -19,6 +19,8 @@ // -------------------------------------------------------------------------------------------------------------------- using System; +using System.Linq; +using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Wordprocessing; using PicklesDoc.Pickles.DocumentationBuilders.Word.Extensions; @@ -57,6 +59,13 @@ public void Format(Body body, ScenarioOutline scenarioOutline) } body.GenerateParagraph(scenarioOutline.Name, "Heading2"); + if (scenarioOutline.Tags.Count != 0) + { + var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Normal" })); + var tagrunProp = new RunProperties(new Italic(), new Color { ThemeColor = ThemeColorValues.Text2 }) { Bold = new Bold() { Val = false } }; + paragraph.Append(new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", scenarioOutline.Tags) + ")"))); + body.Append(paragraph); + } if (!string.IsNullOrEmpty(scenarioOutline.Description)) { body.GenerateParagraph(scenarioOutline.Description, "Normal"); @@ -69,8 +78,22 @@ public void Format(Body body, ScenarioOutline scenarioOutline) foreach (var example in scenarioOutline.Examples) { - body.GenerateParagraph("Examples: " + example.Description, "Heading3"); - this.wordTableFormatter.Format(body, example.TableArgument); + body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading3" }), new Run(new RunProperties(), new Text("Examples:")))); + + if (example.Tags.Count != 0) + { + var tagrunProp = new RunProperties(new Italic(), new Color { ThemeColor = ThemeColorValues.Text2 }) { Bold = new Bold() { Val = false } }; + body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Normal" }), + new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", example.Tags) + ")")))); + } + + if (!string.IsNullOrWhiteSpace(example.Description)) + { + body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Normal" }), + new Run(new Text(example.Description)))); + } + + this.wordTableFormatter.Format( body, example.TableArgument ); } } } diff --git a/src/Pickles/Pickles.ObjectModel/ObjectModel/Example.cs b/src/Pickles/Pickles.ObjectModel/ObjectModel/Example.cs index 47f1408ab..cf269c9b0 100644 --- a/src/Pickles/Pickles.ObjectModel/ObjectModel/Example.cs +++ b/src/Pickles/Pickles.ObjectModel/ObjectModel/Example.cs @@ -18,6 +18,8 @@ // // -------------------------------------------------------------------------------------------------------------------- +using System.Collections.Generic; + namespace PicklesDoc.Pickles.ObjectModel { public class Example @@ -27,5 +29,7 @@ public class Example public string Description { get; set; } public Table TableArgument { get; set; } + + public List Tags { get; set; } } } diff --git a/src/Pickles/Pickles.Test/ObjectModel/Factory.cs b/src/Pickles/Pickles.Test/ObjectModel/Factory.cs index e4b62aca3..ef2475b6f 100644 --- a/src/Pickles/Pickles.Test/ObjectModel/Factory.cs +++ b/src/Pickles/Pickles.Test/ObjectModel/Factory.cs @@ -115,10 +115,10 @@ internal G.Scenario CreateScenario(string[] tags, string name, string descriptio return scenario; } - internal G.Examples CreateExamples(string name, string description, string[] headerCells, IEnumerable exampleRows) + internal G.Examples CreateExamples(string name, string description, string[] headerCells, IEnumerable exampleRows, string[] tags = null) { var examples = new G.Examples( - null, + tags?.Select(this.CreateTag).ToArray(), AnyLocation, "Examples", name, diff --git a/src/Pickles/Pickles.Test/ObjectModel/Json/ExampleToJsonExampleMapperTests.cs b/src/Pickles/Pickles.Test/ObjectModel/Json/ExampleToJsonExampleMapperTests.cs index 9a3c36079..f681885f2 100644 --- a/src/Pickles/Pickles.Test/ObjectModel/Json/ExampleToJsonExampleMapperTests.cs +++ b/src/Pickles/Pickles.Test/ObjectModel/Json/ExampleToJsonExampleMapperTests.cs @@ -18,6 +18,7 @@ // // -------------------------------------------------------------------------------------------------------------------- +using System.Collections.Generic; using NFluent; using NUnit.Framework; @@ -81,6 +82,18 @@ public void Map_AnExampleWithDescription_ReturnsAJsonExampleWithName() Check.That(actual.Description).IsEqualTo("Some description"); } + [Test] + public void Map_AnExampleWithTags_ReturnsAJsonExampleWithTags() + { + var example = new Example { Tags = new List() { "tag1", "tag2" } }; + + var mapper = CreateMapper(); + + var actual = mapper.Map(example); + + Check.That(actual.Tags).ContainsExactly("tag1", "tag2"); + } + [Test] public void Map_AnExampleWithTableArgument_ReturnsAJsonExampleWithTableArgument() { diff --git a/src/Pickles/Pickles.Test/ObjectModel/MapperTestsForExample.cs b/src/Pickles/Pickles.Test/ObjectModel/MapperTestsForExample.cs index ae7cf062d..32145ee8b 100644 --- a/src/Pickles/Pickles.Test/ObjectModel/MapperTestsForExample.cs +++ b/src/Pickles/Pickles.Test/ObjectModel/MapperTestsForExample.cs @@ -65,5 +65,33 @@ public void MapToExample_RegularExamples_ReturnsCorrectExample() Check.That(result.TableArgument.DataRows[0].Cells).ContainsExactly("Row 1, Value 1", "Row 2, Value 2"); Check.That(result.TableArgument.DataRows[1].Cells).ContainsExactly("Row 2, Value 1", "Row 2, Value 2"); } + + [Test] + public void MapToExample_RegularWithTagsExamples_ReturnsCorrectExample() + { + var examples = this.factory.CreateExamples( + "Examples", + "My Description", + new[] { "Header 1", "Header 2" }, + new[] + { + new[] { "Row 1, Value 1", "Row 2, Value 2" }, + new[] { "Row 2, Value 1", "Row 2, Value 2" } + }, + new[] { "tag1", "tag2" } + ); + + var mapper = this.factory.CreateMapper(); + + var result = mapper.MapToExample(examples); + + Check.That(result.Name).IsEqualTo("Examples"); + Check.That(result.Description).IsEqualTo("My Description"); + Check.That(result.TableArgument.HeaderRow.Cells).ContainsExactly("Header 1", "Header 2"); + Check.That(result.TableArgument.DataRows.Count).IsEqualTo(2); + Check.That(result.TableArgument.DataRows[0].Cells).ContainsExactly("Row 1, Value 1", "Row 2, Value 2"); + Check.That(result.TableArgument.DataRows[1].Cells).ContainsExactly("Row 2, Value 1", "Row 2, Value 2"); + Check.That(result.Tags).ContainsExactly("tag1", "tag2"); + } } } diff --git a/src/Pickles/Pickles.sln.DotSettings b/src/Pickles/Pickles.sln.DotSettings index df0b2e90d..ee4ad5200 100644 --- a/src/Pickles/Pickles.sln.DotSettings +++ b/src/Pickles/Pickles.sln.DotSettings @@ -1,7 +1,17 @@  ThisClass All + False USE_FOR_THIS_CLASS + False + False + False + False + False + False + True + False + False -------------------------------------------------------------------------------------------------------------------- <copyright file="$FILENAME$" company="PicklesDoc"> diff --git a/src/Pickles/Pickles/ObjectModel/Mapper.cs b/src/Pickles/Pickles/ObjectModel/Mapper.cs index 27e470ff1..928464012 100644 --- a/src/Pickles/Pickles/ObjectModel/Mapper.cs +++ b/src/Pickles/Pickles/ObjectModel/Mapper.cs @@ -192,7 +192,8 @@ public Example MapToExample(G.Examples examples) { Description = examples.Description, Name = examples.Name, - TableArgument = this.MapToTable(((G.IHasRows) examples).Rows) + TableArgument = this.MapToTable(((G.IHasRows) examples).Rows), + Tags = examples.Tags?.Select(this.MapToString).ToList() }; }