Skip to content

Commit

Permalink
rename Table, Row, Cell to GherkinTable, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed May 24, 2011
1 parent a6873c6 commit 8864c98
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 68 deletions.
6 changes: 3 additions & 3 deletions Generator/SpecFlowUnitTestConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private void GenerateScenarioOutlineTest(CodeTypeDeclaration testType, CodeMembe
}
}

private bool CanUseFirstColumnAsName(Table table)
private bool CanUseFirstColumnAsName(GherkinTable table)
{
if (table.Header.Cells.Length == 0)
return false;
Expand Down Expand Up @@ -387,7 +387,7 @@ private CodeMemberMethod GenerateScenarioOutlineBody(Feature feature, ScenarioOu

private void GenerateScenarioOutlineTestVariant(CodeTypeDeclaration testType, ScenarioOutline scenarioOutline, string testMethodName,
IEnumerable<KeyValuePair<string, string>> paramToIdentifier, string exampleSetTitle, string exampleSetIdentifier,
Row row, Tags exampleSetTags, string variantName)
GherkinTableRow row, Tags exampleSetTags, string variantName)
{
var variantNameIdentifier = variantName.ToIdentifier().TrimStart('_');

Expand Down Expand Up @@ -590,7 +590,7 @@ private void GenerateStep(CodeMemberMethod testMethod, ScenarioStep scenarioStep
}

private int tableCounter = 0;
private CodeExpression GetTableArgExpression(Table tableArg, CodeStatementCollection statements, ParameterSubstitution paramToIdentifier)
private CodeExpression GetTableArgExpression(GherkinTable tableArg, CodeStatementCollection statements, ParameterSubstitution paramToIdentifier)
{
if (tableArg == null)
return new CodeCastExpression(TABLE_TYPE, new CodePrimitiveExpression(null));
Expand Down
2 changes: 1 addition & 1 deletion Parser/GherkinBuilder/ExampleBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ExampleBuilder(string keyword, string name, string description, Tags tags

public ExampleSet GetResult()
{
Table exampleTable = tableBuilder.GetResult();
GherkinTable exampleTable = tableBuilder.GetResult();
if (exampleTable == null)
// this should never happen as the parser checks it already
throw new GherkinSemanticErrorException(
Expand Down
8 changes: 4 additions & 4 deletions Parser/GherkinBuilder/TableBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ namespace TechTalk.SpecFlow.Parser.GherkinBuilder
{
internal class TableBuilder : ITableProcessor
{
private readonly List<Row> tableRows = new List<Row>();
private readonly List<GherkinTableRow> tableRows = new List<GherkinTableRow>();

public Table GetResult()
public GherkinTable GetResult()
{
return tableRows.Count == 0 ? null :
new Table(tableRows[0], tableRows.Skip(1).ToArray());
new GherkinTable(tableRows[0], tableRows.Skip(1).ToArray());
}

public void ProcessTableRow(string[] cells, FilePosition rowPosition)
{
var row = new Row(cells.Select(c => new Cell(c)).ToArray());
var row = new GherkinTableRow(cells.Select(c => new GherkinTableCell(c)).ToArray());
row.FilePosition = rowPosition;

if (tableRows.Count > 0 && tableRows[0].Cells.Length != row.Cells.Length)
Expand Down
4 changes: 2 additions & 2 deletions Parser/SyntaxElements/Examples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class ExampleSet
public string Keyword { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public Table Table { get; set; }
public GherkinTable Table { get; set; }

public ExampleSet()
{
}

public ExampleSet(string keyword, string title, string description, Tags tags, Table table)
public ExampleSet(string keyword, string title, string description, Tags tags, GherkinTable table)
{
Keyword = keyword;
Title = title ?? string.Empty;
Expand Down
55 changes: 55 additions & 0 deletions Parser/SyntaxElements/GherkinTable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Linq;
using System.Xml.Serialization;

namespace TechTalk.SpecFlow.Parser.SyntaxElements
{
[XmlType("Cell")]
public class GherkinTableCell
{
public string Value { get; set; }
public FilePosition FilePosition { get; set; }

public GherkinTableCell()
{
}

public GherkinTableCell(string value)
{
Value = value;
}
}

[XmlType("Row")]
public class GherkinTableRow
{
public GherkinTableCell[] Cells { get; set; }
public FilePosition FilePosition { get; set; }

public GherkinTableRow()
{
}

public GherkinTableRow(params GherkinTableCell[] cells)
{
Cells = cells;
}
}

[XmlType("Table")]
public class GherkinTable
{
public GherkinTableRow Header { get; set; }
public GherkinTableRow[] Body { get; set; }

public GherkinTable()
{
}

public GherkinTable(GherkinTableRow header, params GherkinTableRow[] body)
{
Header = header;
Body = body;
}
}
}
2 changes: 1 addition & 1 deletion Parser/SyntaxElements/ScenarioStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ScenarioStep
public string Keyword { get; set; }
public string Text { get; set; }
public string MultiLineTextArgument { get; set; }
public Table TableArg { get; set; }
public GherkinTable TableArg { get; set; }
public FilePosition FilePosition { get; set; }

public ScenarioStep Clone()
Expand Down
52 changes: 0 additions & 52 deletions Parser/SyntaxElements/Table.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Parser/TechTalk.SpecFlow.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<Compile Include="SyntaxElements\Scenario.cs" />
<Compile Include="SyntaxElements\ScenarioOutline.cs" />
<Compile Include="SyntaxElements\ScenarioStep.cs" />
<Compile Include="SyntaxElements\Table.cs" />
<Compile Include="SyntaxElements\GherkinTable.cs" />
<Compile Include="SyntaxElements\Tag.cs" />
<Compile Include="SyntaxElements\Then.cs" />
<Compile Include="SyntaxElements\When.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,17 @@ private ScenarioStep Clone(ScenarioStep step)
return newStep;
}

private Table Clone(Table table)
private GherkinTable Clone(GherkinTable table)
{
if (table == null)
return null;

return new Table(Clone(table.Header), table.Body.Select(r => Clone(r)).ToArray());
return new GherkinTable(Clone(table.Header), table.Body.Select(r => Clone(r)).ToArray());
}

private Row Clone(Row row)
private GherkinTableRow Clone(GherkinTableRow row)
{
return new Row(row.Cells.Select(c => new Cell(){Value = c.Value}).ToArray());
return new GherkinTableRow(row.Cells.Select(c => new GherkinTableCell(){Value = c.Value}).ToArray());
}

private ScenarioStep CloneTo(ScenarioStep step, string currentBlock)
Expand Down

0 comments on commit 8864c98

Please sign in to comment.