コード例 #1
0
        private void AddPlaceholderTags(ITextSnapshot fileSnapshot, DeveroomTag stepTag, Step step)
        {
            var placeholders = MatchedScenarioOutlinePlaceholder.MatchScenarioOutlinePlaceholders(step);

            foreach (var placeholder in placeholders)
            {
                stepTag.AddChild(new DeveroomTag(DeveroomTagTypes.ScenarioOutlinePlaceholder,
                                                 GetSpan(fileSnapshot, step.Location, placeholder.Length, offset: step.Keyword.Length + placeholder.Index),
                                                 placeholder));
            }
        }
コード例 #2
0
        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));
            }
        }