Example #1
0
        public void When_A_Background_Is_Present_Its_Included_In_Markdown_Output()
        {
            var mockStyle = new MockStylist
            {
                FeatureHeadingFormat    = "FeatureHeading: {0}",
                BackgroundHeadingFormat = "BackgroundHeading: {0}"
            };
            var feature = new Feature
            {
                Name = "Feature with Background"
            };

            feature.AddBackground(new Scenario());

            var featureBlock = new FeatureBlock(feature, mockStyle);
            var results      = new string[featureBlock.Lines.Count];
            var i            = 0;

            foreach (var line in featureBlock.Lines)
            {
                results[i] = line;
                i++;
            }

            Assert.AreEqual("FeatureHeading: Feature with Background", results[0]);
            Assert.AreEqual("BackgroundHeading:", results[2]);
            Assert.AreEqual(3, results.Length);
        }
Example #2
0
        public void A_Table_Is_Formatted_With_Results()
        {
            var mockStyle = new MockStylist
            {
            };

            var table = new Table();

            table.HeaderRow = new TableRow(new[] { "Col1", "Col2" });
            table.DataRows  = new System.Collections.Generic.List <ObjectModel.TableRow>();
            AddRowWithResult(table, new[] { "Col1Row1", "Col2Row1" }, TestResult.Passed);
            AddRowWithResult(table, new[] { "Col1Row2", "Col2Row2" }, TestResult.Failed);
            AddRowWithResult(table, new[] { "Col1Row3", "Col2Row3" }, TestResult.Inconclusive);
            AddRowWithResult(table, new[] { "Col1Row4", "Col2Row4" }, TestResult.NotProvided);

            var tableBlock   = new TableBlock(table, mockStyle, true);
            var actualString = tableBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("> | Col1 | Col2 | Result |", actualString[0]);
            Assert.AreEqual("> | --- | --- | --- |", actualString[1]);
            Assert.AreEqual("> | Col1Row1 | Col2Row1 | ![Passed](pass.png) |", actualString[2]);
            Assert.AreEqual("> | Col1Row2 | Col2Row2 | ![Failed](fail.png) |", actualString[3]);
            Assert.AreEqual("> | Col1Row3 | Col2Row3 | ![Inconclusive](inconclusive.png) |", actualString[4]);
            Assert.AreEqual("> | Col1Row4 | Col2Row4 |  |", actualString[5]);
            Assert.AreEqual(7, actualString.Length);
        }
Example #3
0
        public void When_Mutiple_Scenarios_Are_Available_They_Are_Included_After_Heading()
        {
            var mockStyle = new MockStylist
            {
                FeatureHeadingFormat  = "FeatureHeading: {0}",
                ScenarioHeadingFormat = "ScenarioHeading: {0}"
            };
            var feature = new Feature
            {
                Name = "Feature with Scenario"
            };

            feature.AddFeatureElement(new Scenario()
            {
                Name = "My Scenario one"
            });
            feature.AddFeatureElement(new Scenario()
            {
                Name = "My Scenario two"
            });

            var featureBlock = new FeatureBlock(feature, mockStyle);
            var actualString = featureBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("FeatureHeading: Feature with Scenario", actualString[0]);
            Assert.AreEqual("ScenarioHeading: My Scenario one", actualString[2]);
            Assert.AreEqual("ScenarioHeading: My Scenario two", actualString[4]);
            Assert.AreEqual(7, actualString.Length);
        }
Example #4
0
        public void A_Step_Table_Is_Formatted()
        {
            var mockStyle = new MockStylist
            {
                StepFormat = "Keyword: {0} Step: {1}"
            };
            var step = new Step()
            {
                NativeKeyword = "Natkey ", Name = "I am a step"
            };

            var stepTable = new Table();

            stepTable.HeaderRow = new TableRow(new[] { "Col1", "Col2" });
            stepTable.DataRows  = new System.Collections.Generic.List <ObjectModel.TableRow>();
            stepTable.DataRows.Add(new TableRow(new[] { "Col1Row1", "Col2Row1" }));
            stepTable.DataRows.Add(new TableRow(new[] { "Col1Row2", "Col2Row2" }));
            step.TableArgument = stepTable;

            var stepBlock    = new StepBlock(step, mockStyle);
            var actualString = stepBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("Keyword: Natkey Step: I am a step", actualString[0]);
            Assert.AreEqual(">", actualString[1]);
            Assert.AreEqual("> | Col1 | Col2 |", actualString[2]);
            Assert.AreEqual("> | --- | --- |", actualString[3]);
            Assert.AreEqual("> | Col1Row1 | Col2Row1 |", actualString[4]);
            Assert.AreEqual("> | Col1Row2 | Col2Row2 |", actualString[5]);
            Assert.AreEqual(7, actualString.Length);
        }
Example #5
0
        public void A_New_TitleBlock_Has_Generation_Line()
        {
            var expectedString = "Generated on: ";
            var mockStyle      = new MockStylist();

            var    titleBlock   = new TitleBlock(mockStyle);
            string actualString = titleBlock.ToString();

            Check.That(actualString).Contains(expectedString);
        }
Example #6
0
        public void A_New_TitleBlock_Has_Title_Line()
        {
            var expectedString = "Mocked Title Style: Features";
            var mockStyle      = new MockStylist();

            var    titleBlock   = new TitleBlock(mockStyle);
            string actualString = titleBlock.ToString();

            Check.That(actualString).Contains(expectedString);
        }
Example #7
0
        public void Examples_Are_Included_As_Table()
        {
            var mockStyle = new MockStylist
            {
                ScenarioOutlineHeadingFormat = "ScenarioOutlineHeading: {0}",
                ExampleHeadingFormat         = "ExampleHeading: {0}",
                StepFormat = "Keyword: {0} Step: {1}"
            };
            var scenarioOutline = new ScenarioOutline
            {
                Name = "ScenarioOutline with Examples"
            };

            var examplesTable = new ObjectModel.ExampleTable
            {
                HeaderRow = new ObjectModel.TableRow(new string[] { "example", "val_one", "val_two" }),

                DataRows = new System.Collections.Generic.List <ObjectModel.TableRow>()
            };

            examplesTable.DataRows.Add(new ObjectModel.TableRow(new string[] { "ex.one", "one.one", "one.two" }));
            examplesTable.DataRows.Add(new ObjectModel.TableRow(new string[] { "ex.two", "two.one", "two.two" }));


            var example = new Example()
            {
                Name          = "My Examples",
                TableArgument = examplesTable
            };

            var examples = new System.Collections.Generic.List <Example>()
            {
                example
            };

            scenarioOutline.Examples = examples;

            var scenarioOutlineBlock = new ScenarioOutlineBlock(scenarioOutline, mockStyle);
            var actualString         = scenarioOutlineBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("ScenarioOutlineHeading: ScenarioOutline with Examples", actualString[0]);
            Assert.AreEqual("ExampleHeading: My Examples", actualString[2]);
            Assert.AreEqual("> | example | val_one | val_two |", actualString[4]);
            Assert.AreEqual("> | --- | --- | --- |", actualString[5]);
            Assert.AreEqual("> | ex.one | one.one | one.two |", actualString[6]);
            Assert.AreEqual("> | ex.two | two.one | two.two |", actualString[7]);
            Assert.AreEqual(9, actualString.Length);
        }
Example #8
0
        public void The_Step_Is_Formatted()
        {
            var mockStyle = new MockStylist
            {
                StepFormat = "Keyword: {0} Step: {1}"
            };
            var step = new Step()
            {
                NativeKeyword = "Natkey ", Name = "I am a step"
            };

            var stepBlock    = new StepBlock(step, mockStyle);
            var actualString = stepBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("Keyword: Natkey Step: I am a step", actualString[0]);
            Assert.AreEqual(2, actualString.Length);
        }
Example #9
0
        public void A_New_ScenarioBlock_Has_Scenario_Heading_On_First_Line()
        {
            var expectedString = "SHF: Hello, World";
            var mockStyle      = new MockStylist
            {
                ScenarioHeadingFormat = "SHF: {0}"
            };
            var scenario = new Scenario
            {
                Name = "Hello, World"
            };

            var scenarioBlock = new ScenarioBlock(scenario, mockStyle);
            var actualString  = scenarioBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual(expectedString, actualString[0]);
            Assert.AreEqual(2, actualString.Length);
        }
Example #10
0
        public void A_New_FeatureBlock_Has_Feature_Heading_On_First_Line()
        {
            var expectedString = "FHF: Hello, World";
            var mockStyle      = new MockStylist
            {
                FeatureHeadingFormat = "FHF: {0}"
            };
            var feature = new Feature
            {
                Name = "Hello, World"
            };

            var featureBlock = new FeatureBlock(feature, mockStyle);
            var actualString = featureBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual(expectedString, actualString[0]);
            Assert.AreEqual(3, actualString.Length);
        }
Example #11
0
        public void When_A_Scenario_Step_Has_A_Result__The_Result_Is_Included()
        {
            var mockStyle = new MockStylist
            {
                ScenarioHeadingFormat = "ScenarioHeading: {0}",
                StepFormat            = "Keyword: {0} Step: {1}"
            };
            var scenario = new Scenario
            {
                Name   = "Scenario with Step",
                Result = TestResult.Passed
            };

            var scenarioBlock = new ScenarioBlock(scenario, mockStyle);
            var actualString  = scenarioBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("ScenarioHeading: result Scenario with Step", actualString[0]);
            Assert.AreEqual(2, actualString.Length);
        }
Example #12
0
        public void A_Table_Is_Formatted_With_Placeholders()
        {
            var mockStyle = new MockStylist
            {
            };

            var table = new Table();

            table.HeaderRow = new TableRow(new[] { "Col1", "Col2" });
            table.DataRows  = new System.Collections.Generic.List <ObjectModel.TableRow>();
            table.DataRows.Add(new TableRow(new[] { "Col1Row1", "<Col2Row1>" }));
            table.DataRows.Add(new TableRow(new[] { "<Col1Row2>", "Col2Row2" }));

            var tableBlock   = new TableBlock(table, mockStyle);
            var actualString = tableBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("> | Col1 | Col2 |", actualString[0]);
            Assert.AreEqual("> | --- | --- |", actualString[1]);
            Assert.AreEqual(@"> | Col1Row1 | \<Col2Row1\> |", actualString[2]);
            Assert.AreEqual(@"> | \<Col1Row2\> | Col2Row2 |", actualString[3]);
            Assert.AreEqual(5, actualString.Length);
        }
Example #13
0
        public void When_Scenario_Tags_Available_They_Are_Placed_On_Single_Line_Before_Heading()
        {
            var mockStyle = new MockStylist
            {
                ScenarioHeadingFormat = "ScenarioHeading: {0}",
                TagFormat             = ">>>{0}<<<"
            };
            var scenario = new Scenario
            {
                Name = "Scenario with Tags"
            };

            scenario.Tags.Add("tagone");
            scenario.Tags.Add("tagtwo");

            var scenarioBlock = new ScenarioBlock(scenario, mockStyle);
            var actualString  = scenarioBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual(">>>tagone<<< >>>tagtwo<<<", actualString[0]);
            Assert.AreEqual("ScenarioHeading: Scenario with Tags", actualString[2]);
            Assert.AreEqual(4, actualString.Length);
        }
Example #14
0
        public void When_Feature_Tags_Available_They_Are_Placed_On_Single_Line_Before_Heading()
        {
            var mockStyle = new MockStylist
            {
                FeatureHeadingFormat = "FeatureHeading: {0}",
                TagFormat            = ">>>{0}<<<"
            };
            var feature = new Feature
            {
                Name = "Feature with Tags"
            };

            feature.AddTag("tagone");
            feature.AddTag("tagtwo");

            var featureBlock = new FeatureBlock(feature, mockStyle);
            var actualString = featureBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual(">>>tagone<<< >>>tagtwo<<<", actualString[0]);
            Assert.AreEqual("FeatureHeading: Feature with Tags", actualString[2]);
            Assert.AreEqual(5, actualString.Length);
        }
Example #15
0
        public void When_Feature_Description_Available_It_Is_Placed_Below_Feature_Heading()
        {
            var mockStyle = new MockStylist
            {
                FeatureHeadingFormat = "FeatureHeading: {0}"
            };
            var feature = new Feature
            {
                Name        = "Feature with description",
                Description = String.Concat(
                    "In order to determine that world is flat", Environment.NewLine,
                    "As a captain of a ship", Environment.NewLine,
                    "I want to sail beyond the horizion")
            };

            var featureBlock = new FeatureBlock(feature, mockStyle);
            var actualString = featureBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("FeatureHeading: Feature with description", actualString[0]);
            Assert.AreEqual("In order to determine that world is flat", actualString[2]);
            Assert.AreEqual("As a captain of a ship", actualString[4]);
            Assert.AreEqual("I want to sail beyond the horizion", actualString[6]);
            Assert.AreEqual(9, actualString.Length);
        }
Example #16
0
        public void When_A_ScenarioOutline_Step_Is_Available_It_Has_Escape_Characters_For_Placeholder_Brackets()
        {
            var mockStyle = new MockStylist
            {
                ScenarioOutlineHeadingFormat = "ScenarioOutlineHeading: {0}",
                StepFormat = "Keyword: {0} Step: {1}"
            };
            var scenarioOutline = new ScenarioOutline
            {
                Name = "ScenarioOutline with placeholder Step"
            };

            scenarioOutline.Steps.Add(new Step()
            {
                NativeKeyword = "Natkey ", Name = "I am a <placeholder> step"
            });

            var scenarioOutlineBlock = new ScenarioOutlineBlock(scenarioOutline, mockStyle);
            var actualString         = scenarioOutlineBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("ScenarioOutlineHeading: ScenarioOutline with placeholder Step", actualString[0]);
            Assert.AreEqual(@"Keyword: Natkey Step: I am a \<placeholder\> step", actualString[2]);
            Assert.AreEqual(4, actualString.Length);
        }
Example #17
0
        public void When_A_Scenario_Step_Is_Available_It_Is_Placed_On_Single_Line_After_Heading()
        {
            var mockStyle = new MockStylist
            {
                ScenarioHeadingFormat = "ScenarioHeading: {0}",
                StepFormat            = "Keyword: {0} Step: {1}"
            };
            var scenario = new Scenario
            {
                Name = "Scenario with Step"
            };

            scenario.Steps.Add(new Step()
            {
                NativeKeyword = "Natkey ", Name = "I am a step"
            });

            var scenarioBlock = new ScenarioBlock(scenario, mockStyle);
            var actualString  = scenarioBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("ScenarioHeading: Scenario with Step", actualString[0]);
            Assert.AreEqual("Keyword: Natkey Step: I am a step", actualString[2]);
            Assert.AreEqual(4, actualString.Length);
        }