public List <NodeFeature> Load(string[] contents) { bool isBuildingExampleTable = false; bool isHeaderRow = false; // since we read top to bottom, sometimes we don't know if a hook is for the next scenario or a new feature foreach (string line in contents) { string formattedLine = line.Trim(); string label = GherkinParser.DetermineLabel(formattedLine); if (label != EnumNames.slim) { isBuildingExampleTable = false; // reset at start of new label other than slims } switch (label) { case EnumNames.hook: AddHook(formattedLine); break; case EnumNames.Feature: AddFeature(formattedLine, label); break; case EnumNames.Scenario: lastScenario = new NodeScenario(GherkinParser.ParseNameWithLabel(formattedLine, label), scenarioHooks); AddScenario(lastScenario); break; case EnumNames.ScenarioOutline: lastScenario = new NodeScenarioOutline(GherkinParser.ParseNameWithLabel(formattedLine, label), scenarioHooks); AddScenario(lastScenario); break; case EnumNames.Examples: isBuildingExampleTable = true; isHeaderRow = true; break; case EnumNames.Given: case EnumNames.When: case EnumNames.Then: case EnumNames.And: AddStep(formattedLine); break; case EnumNames.slim: if (isHeaderRow) { formattedLine = GherkinParser.RemoveWhiteSpace(formattedLine); } if (isBuildingExampleTable) { AddExampleRow(formattedLine); } else { AddTableRow(formattedLine); } isHeaderRow = false; break; default: // do nothing break; } } return(features); }