public UsageFinderContext(object node, IGherkinDocumentContext parent = null) { Node = node; Parent = parent; }
public TagMatchingContext(IGherkinDocumentContext parent, object node) { Parent = parent; Node = node; }
public static IEnumerable <KeyValuePair <string, IGherkinDocumentContext> > GetBackgroundStepsWithContexts(Step step, IGherkinDocumentContext context) { return(GetBackgroundContexts(context).Distinct(TagMatchingContextComparer.Instance) .Select(ctx => new KeyValuePair <string, IGherkinDocumentContext>(step.Text, ctx))); }
public static bool IsBackground(this IGherkinDocumentContext context) => context?.Node is Background;
public static IEnumerable <KeyValuePair <string, IGherkinDocumentContext> > GetScenarioOutlineStepsWithContexts(Step step, IGherkinDocumentContext context) { var scenarioOutline = (ScenarioOutline)context.Node; var subContext = context; bool hasExamples = false; foreach (var scenarioOutlineExamples in scenarioOutline.Examples) { var exampleTags = EnsureArray(scenarioOutlineExamples.Tags); if (exampleTags != null && exampleTags.Any()) { subContext = new TagMatchingContext(context, scenarioOutlineExamples); } if (scenarioOutlineExamples.TableHeader != null && scenarioOutlineExamples.TableBody != null) { var header = scenarioOutlineExamples.TableHeader.Cells.Select(c => c.Value).ToArray(); foreach (var exampleRow in scenarioOutlineExamples.TableBody) { hasExamples = true; var stepText = MatchedScenarioOutlinePlaceholder.ReplaceScenarioOutlinePlaceholders(step, match => { int headerIndex = Array.IndexOf(header, match.Name); if (headerIndex < 0) { return(match.Value); } return(exampleRow.Cells.ElementAtOrDefault(headerIndex)?.Value ?? match.Value); }); yield return(new KeyValuePair <string, IGherkinDocumentContext>(stepText, subContext)); } } } if (!hasExamples) { // for empty SO, we create a context with the original step text (incl. placeholders) yield return(new KeyValuePair <string, IGherkinDocumentContext>(step.Text, context)); } }
public static bool IsScenarioOutline(this IGherkinDocumentContext context) => context?.Node is ScenarioOutline;
public static IEnumerable <string> GetTagNames(this IGherkinDocumentContext context) => context.GetTags().Select(t => t.Name);
public static IEnumerable <Tag> GetTags(this IGherkinDocumentContext context) { return(context.GetNodes <IHasTags>().SelectMany(ht => ht.Tags)); }
public static IEnumerable <T> GetNodes <T>(this IGherkinDocumentContext context) => context.GetNodes().OfType <T>();
public static bool IsRoot(this IGherkinDocumentContext context) => context.Parent == null;