private TableCell ConvertCell(Ast.TableCell c) { return(new TableCell() { Value = CucumberMessagesDefaults.UseDefault(c.Value, CucumberMessagesDefaults.DefaultCellValue), Location = ConvertLocation(c.Location) }); }
private Tuple <Background, Rule, Scenario> ConvertToChild(IHasLocation hasLocation) { switch (hasLocation) { case Gherkin.Ast.Background background: var backgroundSteps = background.Steps.Select(ConvertStep).ToList(); return(new Tuple <Background, Rule, Scenario>(new Background { Id = _idGenerator.GetNewId(), Location = ConvertLocation(background.Location), Name = CucumberMessagesDefaults.UseDefault(background.Name, CucumberMessagesDefaults.DefaultName), Description = CucumberMessagesDefaults.UseDefault(background.Description, CucumberMessagesDefaults.DefaultDescription), Keyword = background.Keyword, Steps = backgroundSteps }, null, null)); case Ast.Scenario scenario: var steps = scenario.Steps.Select(ConvertStep).ToList(); var examples = scenario.Examples.Select(ConvertExamples).ToReadOnlyCollection(); var tags = scenario.Tags.Select(ConvertTag).ToReadOnlyCollection(); return(new Tuple <Background, Rule, Scenario>(null, null, new Scenario() { Id = _idGenerator.GetNewId(), Keyword = scenario.Keyword, Location = ConvertLocation(scenario.Location), Name = CucumberMessagesDefaults.UseDefault(scenario.Name, CucumberMessagesDefaults.DefaultName), Description = CucumberMessagesDefaults.UseDefault(scenario.Description, CucumberMessagesDefaults.DefaultDescription), Steps = steps, Examples = examples, Tags = tags })); case Ast.Rule rule: { var ruleChildren = rule.Children.Select(ConvertToRuleChild).ToReadOnlyCollection(); var ruleTags = rule.Tags.Select(ConvertTag).ToReadOnlyCollection(); return(new Tuple <Background, Rule, Scenario>(null, new Rule { Id = _idGenerator.GetNewId(), Name = CucumberMessagesDefaults.UseDefault(rule.Name, CucumberMessagesDefaults.DefaultName), Description = CucumberMessagesDefaults.UseDefault(rule.Description, CucumberMessagesDefaults.DefaultDescription), Keyword = rule.Keyword, Children = ruleChildren, Location = ConvertLocation(rule.Location), Tags = ruleTags }, null)); } default: throw new NotImplementedException(); } }
private Examples ConvertExamples(Ast.Examples examples) { var header = ConvertTableHeader(examples); var body = ConvertToTableBody(examples); var tags = examples.Tags.Select(ConvertTag).ToReadOnlyCollection(); return(new Examples() { Id = _idGenerator.GetNewId(), Name = CucumberMessagesDefaults.UseDefault(examples.Name, CucumberMessagesDefaults.DefaultName), Keyword = examples.Keyword, Description = CucumberMessagesDefaults.UseDefault(examples.Description, CucumberMessagesDefaults.DefaultDescription), Location = ConvertLocation(examples.Location), TableHeader = header, TableBody = body, Tags = tags }); }
private Feature ConvertFeature(Ast.GherkinDocument gherkinDocument) { var feature = gherkinDocument.Feature; if (feature == null) { return(null); } var children = feature.Children.Select(ConvertToFeatureChild).ToReadOnlyCollection(); var tags = feature.Tags.Select(ConvertTag).ToReadOnlyCollection(); return(new Feature() { Name = CucumberMessagesDefaults.UseDefault(feature.Name, CucumberMessagesDefaults.DefaultName), Description = CucumberMessagesDefaults.UseDefault(feature.Description, CucumberMessagesDefaults.DefaultDescription), Keyword = feature.Keyword, Language = feature.Language, Location = ConvertLocation(feature.Location), Children = children, Tags = tags }); }