コード例 #1
0
        public IEnumerable <IEnumerable <string> > GetRows(string args, string path, ExamplesHeader header)
        {
            var file = new FileInfo(path);

            args = args.Length > TagName.Length + 1 ? args.Substring(TagName.Length + 1) : null;
            return(GetRowsInternal(args, file.DirectoryName, file.Name, header));
        }
コード例 #2
0
        private Examples HandleTags(Examples example, SpecFlowDocument doc)
        {
            if (example.Tags == null)
            {
                return(example);
            }

            var unhandled = example.Tags.ToList();

            var header = new ExamplesHeader(example.TableHeader.Cells.Select(c => c.Value));

            var rows = new List <TableRow>();

            foreach (var generator in container.GetGenerators())
            {
                foreach (var tag in example.Tags)
                {
                    var name = tag.SanitiseTag();
                    if (!generator.Handles(name))
                    {
                        continue;
                    }

                    unhandled.Remove(tag);

                    var generated = generator.GetRows(name, doc.SourceFilePath, header)
                                    .Select(r => r.ToTableRow(doc))
                                    .ToList();

                    if (!generated.Any())
                    {
                        throw new SemanticParserException($"Generator '{name}' returned no examples", tag.Location);
                    }

                    rows.AddRange(generated);
                }
            }

            return(!rows.Any()
                ? example
                : example.Clone(tags: unhandled, body: example.TableBody.Concat(RowSorter.MaybeSortRows(example.TableHeader, rows))));
        }
コード例 #3
0
 public abstract IEnumerable <IEnumerable <string> > GetRowsInternal(string args, string dir, string specfile, ExamplesHeader header);