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); }
private ObjectModel.ExampleTable ConvertSpecflowTableToExamplesTable(TechTalk.SpecFlow.Table specflowTable) { var exampleTable = new ObjectModel.ExampleTable { HeaderRow = new ObjectModel.TableRow(specflowTable.Header), DataRows = new System.Collections.Generic.List <ObjectModel.TableRow>() }; foreach (var row in specflowTable.Rows) { exampleTable.DataRows.Add(new ObjectModel.TableRow(row.Values)); } return(exampleTable); }
private ObjectModel.ExampleTable ConvertSpecflowTableToExamplesWithResultsTable(TechTalk.SpecFlow.Table specflowTable) { // Rest In Peace, Marshall 2018-12-12 var columnCount = specflowTable.Header.Count - 1; var resultLocation = specflowTable.Header.Count - 1; var headerRow = new string[columnCount]; int i = 0; foreach (var header in specflowTable.Header) { headerRow[i] = header; i++; if (i == columnCount) { break; } } var exampleTable = new ObjectModel.ExampleTable { HeaderRow = new ObjectModel.TableRow(headerRow), DataRows = new System.Collections.Generic.List <ObjectModel.TableRow>() }; foreach (var row in specflowTable.Rows) { var tableRow = new string[columnCount]; int r = 0; foreach (var rowValue in row.Values) { tableRow[r] = rowValue; r++; if (r == columnCount) { break; } } var outcome = row[resultLocation]; var gherkinTableRow = new ObjectModel.TableRowWithTestResult(tableRow); switch (outcome) { case "passed": gherkinTableRow.Result = TestResult.Passed; break; case "failed": gherkinTableRow.Result = TestResult.Failed; break; case "inconclusive": gherkinTableRow.Result = TestResult.Inconclusive; break; default: break; } exampleTable.DataRows.Add(gherkinTableRow); } return(exampleTable); }