public TableRow MapToTableRow(G.TableRow tableRow) { if (tableRow == null) { return null; } return new TableRow(tableRow.Cells.Select(this.MapToString)); }
public Table MapToTable(G.DataTable dataTable) { if (dataTable == null) { return null; } var tableRows = dataTable.Rows; return this.MapToTable(tableRows); }
internal G.Scenario CreateScenario(string[] tags, string name, string description, G.Step[] steps) { G.Scenario scenario = new G.Scenario( tags.Select(this.CreateTag).ToArray(), AnyLocation, "Scenario", name, description, steps); return scenario; }
public Step MapToStep(G.Step step) { if (step == null) { return null; } return new Step { Location = this.MapToLocation(step.Location), DocStringArgument = step.Argument is G.DocString ? this.MapToString((G.DocString) step.Argument) : null, Keyword = this.MapToKeyword(step.Keyword), NativeKeyword = step.Keyword, Name = step.Text, TableArgument = step.Argument is G.DataTable ? this.MapToTable((G.DataTable) step.Argument) : null, }; }
public Example MapToExample(G.Examples examples) { if (examples == null) { return null; } return new Example { Description = examples.Description, Name = examples.Name, TableArgument = this.MapToTable(((G.IHasRows) examples).Rows) }; }
public Scenario MapToScenario(G.Scenario scenario) { if (scenario == null) { return null; } return new Scenario { Description = scenario.Description ?? string.Empty, Location = this.MapToLocation(scenario.Location), Name = scenario.Name, Slug = scenario.Name.ToSlug(), Steps = scenario.Steps.Select(this.MapToStep).ToList(), Tags = scenario.Tags.Select(this.MapToString).ToList() }; }
public TableRow MapToTableRow(G.TableRow tableRow) { return this.mapper.Map<TableRow>(tableRow); }
internal G.Background CreateBackground(string name, string description, G.Step[] steps) { G.Background background = new G.Background( AnyLocation, "Background", name, description, steps); return background; }
public Step MapToStep(G.Step step) { return this.mapper.Map<Step>(step); }
public string MapToString(G.TableCell cell) { return cell?.Value; }
public Feature MapToFeature(G.GherkinDocument gherkinDocument) { if (gherkinDocument == null) { return null; } var feature = new Feature(); var background = gherkinDocument.Feature.Children.SingleOrDefault(c => c is G.Background) as G.Background; if (background != null) { feature.AddBackground(this.MapToScenario(background)); } if (this.configuration.ShouldEnableComments) { feature.Comments.AddRange((gherkinDocument.Comments ?? new G.Comment[0]).Select(this.MapToComment)); } feature.Description = gherkinDocument.Feature.Description ?? string.Empty; foreach (var featureElement in gherkinDocument.Feature.Children.Where(c => !(c is G.Background))) { feature.AddFeatureElement(this.MapToFeatureElement(featureElement)); } feature.Name = gherkinDocument.Feature.Name; foreach (var tag in gherkinDocument.Feature.Tags) { feature.AddTag(this.MapToString(tag)); } foreach (var comment in feature.Comments.ToArray()) { // Find the related feature var relatedFeatureElement = feature.FeatureElements.LastOrDefault(x => x.Location.Line < comment.Location.Line); // Find the step to which the comment is related to if (relatedFeatureElement != null) { var stepAfterComment = relatedFeatureElement.Steps.FirstOrDefault(x => x.Location.Line > comment.Location.Line); if (stepAfterComment != null) { // Comment is before a step comment.Type = CommentType.StepComment; stepAfterComment.Comments.Add(comment); } else { // Comment is located after the last step var stepBeforeComment = relatedFeatureElement.Steps.LastOrDefault(x => x.Location.Line < comment.Location.Line); if (stepBeforeComment != null && stepBeforeComment == relatedFeatureElement.Steps.Last()) { comment.Type = CommentType.AfterLastStepComment; stepBeforeComment.Comments.Add(comment); } } } } foreach (var featureElement in feature.FeatureElements.ToArray()) { featureElement.Feature = feature; } if (feature.Background != null) { feature.Background.Feature = feature; } return feature; }
public Feature MapToFeature(G.Feature feature) { return this.mapper.Map<Feature>(feature); }
public Scenario MapToScenario(G.Background background) { return this.mapper.Map<Scenario>(background); }
public ScenarioOutline MapToScenarioOutline(G.ScenarioOutline scenarioOutline) { return this.mapper.Map<ScenarioOutline>(scenarioOutline); }
public Example MapToExample(G.Examples examples) { return this.mapper.Map<Example>(examples); }
public Scenario MapToScenario(G.Scenario scenario) { return this.mapper.Map<Scenario>(scenario); }
public string MapToString(G.Tag tag) { return this.mapper.Map<string>(tag); }
public ScenarioOutline MapToScenarioOutline(G.ScenarioOutline scenarioOutline) { if (scenarioOutline == null) { return null; } return new ScenarioOutline { Description = scenarioOutline.Description ?? string.Empty, Examples = (scenarioOutline.Examples ?? new G.Examples[0]).Select(this.MapToExample).ToList(), Location = this.MapToLocation(scenarioOutline.Location), Name = scenarioOutline.Name, Slug = scenarioOutline.Name.ToSlug(), Steps = scenarioOutline.Steps.Select(this.MapToStep).ToList(), Tags = scenarioOutline.Tags.Select(this.MapToString).ToList() }; }
public Scenario MapToScenario(G.Background background) { if (background == null) { return null; } return new Scenario { Description = background.Description ?? string.Empty, Location = this.MapToLocation(background.Location), Name = background.Name, Steps = background.Steps.Select(this.MapToStep).ToList(), }; }
internal G.Feature CreateFeature(string name, string description, string[] tags = null, G.Background background = null, G.ScenarioDefinition[] scenarioDefinitions = null) { return new G.Feature((tags ?? new string[0]).Select(this.CreateTag).ToArray(), null, null, "Feature", name, description, background, scenarioDefinitions, null); }
private IFeatureElement MapToFeatureElement(G.ScenarioDefinition sd) { if (sd == null) { return null; } var scenario = sd as G.Scenario; if (scenario != null) { return this.MapToScenario(scenario); } var scenarioOutline = sd as G.ScenarioOutline; if (scenarioOutline != null) { return this.MapToScenarioOutline(scenarioOutline); } var background = sd as G.Background; if (background != null) { return this.MapToScenario(background); } throw new ArgumentException("Only arguments of type Scenario, ScenarioOutline and Background are supported."); }
public Table MapToTable(G.DataTable dataTable) { return this.mapper.Map<Table>(dataTable); }
public string MapToString(G.Tag tag) { return tag?.Name; }
public string MapToString(G.DocString docString) { return this.mapper.Map<string>(docString); }
public string MapToString(G.DocString docString) { return docString?.Content; }
public Comment MapToComment(G.Comment comment) { if (comment == null) { return null; } return new Comment { Text = comment.Text.Trim(), Location = this.MapToLocation(comment.Location) }; }
internal G.ScenarioOutline CreateScenarioOutline(string[] tags, string name, string description, G.Step[] steps, G.Examples[] examples) { G.ScenarioOutline scenarioOutline = new G.ScenarioOutline( tags.Select(this.CreateTag).ToArray(), AnyLocation, "Scenario", name, description, steps, examples); return scenarioOutline; }
public Location MapToLocation(G.Location location) { return location != null ? new Location { Column = location.Column, Line = location.Line } : null; }
internal G.GherkinDocument CreateGherkinDocument(string name, string description, string[] tags = null, G.Background background = null, G.ScenarioDefinition[] scenarioDefinitions = null, G.Comment[] comments = null, G.Location location = null) { var nonNullScenarioDefinitions = scenarioDefinitions ?? new G.ScenarioDefinition[0]; return new G.GherkinDocument( new G.Feature( (tags ?? new string[0]).Select(this.CreateTag).ToArray(), location, null, "Feature", name, description, background != null ? new G.ScenarioDefinition[] { background }.Concat(nonNullScenarioDefinitions).ToArray() : nonNullScenarioDefinitions), comments); }
public string MapToString(G.TableCell cell) { return this.mapper.Map<string>(cell); }