Skip to content

Commit

Permalink
Only Example have TableData with results (#515)
Browse files Browse the repository at this point in the history
* Version 2.16.2 (#483)

* Pickles is unable to deal with Danish characters (#477)

* Version 2.16.2

* Version 2.17.0

* fix Scenario outline export

* correction clean the code and create specific class/function with testResults

* fix forgotten scripts after rename

* fix to valid tests
  • Loading branch information
spacehole1 authored and dirkrombauts committed Apr 19, 2018
1 parent b5304a4 commit e170a57
Show file tree
Hide file tree
Showing 23 changed files with 294 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class WhenAddingAScenarioOutlineToAWorksheet : BaseFixture
public void ThenSingleScenarioOutlineAddedSuccessfully()
{
var excelScenarioFormatter = Container.Resolve<ExcelScenarioOutlineFormatter>();
var exampleTable = new Table();
var exampleTable = new ExampleTable();
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") });
new List<TableRow>(new[] { new TableRowWithTestResult("1", "2", "3", "4"), new TableRowWithTestResult("5", "6", "7", "8") });
var example = new Example { Name = "Examples", Description = string.Empty, TableArgument = exampleTable };
var examples = new List<Example>();
examples.Add(example);
Expand Down Expand Up @@ -87,10 +87,10 @@ public void ThenSingleScenarioOutlineAddedSuccessfully()
public void ThenSingleScenarioOutlineWithStepsAddedSuccessfully()
{
var excelScenarioFormatter = Container.Resolve<ExcelScenarioOutlineFormatter>();
var exampleTable = new Table();
var exampleTable = new ExampleTable();
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") });
new List<TableRow>(new[] { new TableRowWithTestResult("1", "2", "3", "4"), new TableRowWithTestResult("5", "6", "7", "8") });
var example = new Example { Name = "Examples", Description = string.Empty, TableArgument = exampleTable };
var examples = new List<Example>();
examples.Add(example);
Expand Down Expand Up @@ -162,7 +162,7 @@ private static ScenarioOutline SetupScenarioOutline()
{
Name = "Examples",
Description = string.Empty,
TableArgument = new Table
TableArgument = new ExampleTable
{
HeaderRow = new TableRow(),
DataRows = new List<TableRow>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,45 @@ public void Format(IXLWorksheet worksheet, Table table, ref int row)
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.RightBorder =
XLBorderStyleValues.Thin;
}


public void Format(IXLWorksheet worksheet, ExampleTable table, ref int row)
{
int startRow = row;
int headerColumn = TableStartColumn;
foreach (string cell in table.HeaderRow.Cells)
{
worksheet.Cell(row, headerColumn).Style.Font.SetBold();
worksheet.Cell(row, headerColumn).Style.Font.SetItalic();
worksheet.Cell(row, headerColumn).Style.Fill.SetBackgroundColor(XLColor.AliceBlue);
worksheet.Cell(row, headerColumn++).Value = cell;
}

row++;

foreach (TableRow dataRow in table.DataRows)
{
int dataColumn = TableStartColumn;
foreach (string cell in dataRow.Cells)
{
worksheet.Cell(row, dataColumn++).Value = cell;
}

row++;
}

int lastRow = row - 1;
int lastColumn = headerColumn - 1;

worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.LeftBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.BottomBorder =
XLBorderStyleValues.Thin;
worksheet.Range(startRow, TableStartColumn, lastRow, lastColumn).Style.Border.RightBorder =
XLBorderStyleValues.Thin;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class WhenFormattingScenarioOutlines : BaseFixture
[Test]
public void ThenCanFormatCompleteScenarioOutlineCorrectly()
{
var table = new Table
var table = new ExampleTable
{
HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
DataRows =
Expand Down Expand Up @@ -71,7 +71,7 @@ public void ThenCanFormatCompleteScenarioOutlineCorrectly()
[Test]
public void ThenCanFormatScenarioOutlineWithMissingNameCorrectly()
{
var table = new Table
var table = new ExampleTable
{
HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
DataRows =
Expand Down Expand Up @@ -102,7 +102,7 @@ public void ThenCanFormatScenarioOutlineWithMissingNameCorrectly()
[Test]
public void ThenCanFormatScenarioOutlineWithMissingDescriptionCorrectly()
{
var table = new Table
var table = new ExampleTable
{
HeaderRow = new TableRow("Var1", "Var2", "Var3", "Var4"),
DataRows =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.IO;
using System.Text.RegularExpressions;
using Autofac;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,180 +153,91 @@ Scenario: A feature with a table
"DataRows": [
[
"Chapter 1",
"1",
{
"WasExecuted": false,
"WasSuccessful": false
}
"1"
],
[
"Chapter 2",
"5",
{
"WasExecuted": false,
"WasSuccessful": false
}
"5"
],
[
"Chapter 3",
"10",
{
"WasExecuted": false,
"WasSuccessful": false
}
"10"
],
[
"Chapter 4",
"15",
{
"WasExecuted": false,
"WasSuccessful": false
}
"15"
],
[
"Chapter 5",
"20",
{
"WasExecuted": false,
"WasSuccessful": false
}
"20"
],
[
"Chapter 6",
"25",
{
"WasExecuted": false,
"WasSuccessful": false
}
"25"
],
[
"Chapter 7",
"30",
{
"WasExecuted": false,
"WasSuccessful": false
}
"30"
],
[
"Chapter 8",
"35",
{
"WasExecuted": false,
"WasSuccessful": false
}
"35"
],
[
"Chapter 9",
"40",
{
"WasExecuted": false,
"WasSuccessful": false
}
"40"
],
[
"Chapter 10",
"45",
{
"WasExecuted": false,
"WasSuccessful": false
}
"45"
],
[
"Chapter 11",
"50",
{
"WasExecuted": false,
"WasSuccessful": false
}
"50"
],
[
"Chapter 12",
"55",
{
"WasExecuted": false,
"WasSuccessful": false
}
"55"
],
[
"Chapter 13",
"60",
{
"WasExecuted": false,
"WasSuccessful": false
}
"60"
],
[
"Chapter 14",
"65",
{
"WasExecuted": false,
"WasSuccessful": false
}
"65"
],
[
"Chapter 15",
"70",
{
"WasExecuted": false,
"WasSuccessful": false
}
"70"
],
[
"Chapter 16",
"75",
{
"WasExecuted": false,
"WasSuccessful": false
}
"75"
],
[
"Chapter 17",
"80",
{
"WasExecuted": false,
"WasSuccessful": false
}
"80"
],
[
"Chapter 18",
"85",
{
"WasExecuted": false,
"WasSuccessful": false
}
"85"
],
[
"Chapter 19",
"90",
{
"WasExecuted": false,
"WasSuccessful": false
}
"90"
],
[
"Chapter 20",
"95",
{
"WasExecuted": false,
"WasSuccessful": false
}
"95"
],
[
"Chapter 21",
"100",
{
"WasExecuted": false,
"WasSuccessful": false
}
"100"
],
[
"Chapter 22",
"105",
{
"WasExecuted": false,
"WasSuccessful": false
}
"105"
]
]
},
Expand Down
Loading

0 comments on commit e170a57

Please sign in to comment.