示例#1
0
        /// <summary>
        /// Reads the contents of the file to the feature.
        /// </summary>
        /// <param name="text">The text to read.</param>
        /// <param name="feature">The feature.</param>
        public void ReadTo(string text, Feature feature)
        {
            this.CompileRegexes(text);

            List <string> lines = TextParser.GetLines(text);

            Scenario scenario = null;
            StepType stepType = StepType.Unknown;

            for (int i = 0; i < lines.Count; i++)
            {
                string line = lines[i];

                if (scenario == null)
                {
                    this.match = this.headerRegex.Match(line);

                    if (this.match.Success)
                    {
                        feature.Headers[this.match.Groups[1].Value] = this.match.Groups[2].Value;

                        continue;
                    }

                    if (this.commentRegex.IsMatch(line))
                    {
                        continue;
                    }

                    i = this.ParseTitleAndDescription(lines, i, feature);
                }
                else
                {
                    if (this.commentRegex.IsMatch(line))
                    {
                        continue;
                    }

                    this.match = this.scenarioRegex.Match(line);
                }

                if (this.match.Success)
                {
                    scenario = CreateScenario(feature, this.match.Groups[1].Value, out stepType);
                }
                else
                {
                    if (scenario == null)
                    {
                        scenario = CreateScenario(feature, null, out stepType);
                    }

                    this.ParseStep(lines, ref i, scenario, ref stepType, line);
                }
            }
        }
示例#2
0
        void IBlockReporter <Text> .ReportBlock(Text block)
        {
            _writer.WriteLine("<blockquote>");

            foreach (var line in TextParser.GetLines(block.StringBuilder.ToString()))
            {
                _writer.WriteLine(line);
            }

            _writer.WriteLine("</blockquote>");
        }
示例#3
0
        /// <summary>
        /// Formats this instance.
        /// </summary>
        /// <returns>A <c>string</c> representing the block.</returns>
        public string Format()
        {
            var lines = TextParser.GetLines(this.stringBuilder.ToString());

            var sb = new StringBuilder();

            foreach (var line in lines)
            {
                sb.AppendLine("    > " + line);
            }

            return(sb.ToString());
        }
示例#4
0
        public override IBlock Parse(string text)
        {
            var form = new Form();

            Match m;

            List <string> lines = TextParser.GetLines(text);
            int           i     = 0;

            while (i < lines.Count && (m = FormRegex.Match(lines[i])).Success)
            {
                string label = m.Groups[1].Value;
                string value = m.Groups[2].Value;

                form.Add(label, value);

                i++;
            }

            return(form);
        }
示例#5
0
        public override IBlock Parse(string text)
        {
            var grid = new Grid();

            List <string> lines = TextParser.GetLines(text);
            int           i     = 0;

            List <string> headers = SplitCells(lines[i]);

            grid.SetHeaders(headers);

            i++;

            while (i < lines.Count && GridRegex.IsMatch(lines[i]))
            {
                grid.AddValues(SplitCells(lines[i]));
                i++;
            }

            return(grid);
        }
示例#6
0
        public override IBlock Parse(string text)
        {
            var sb = new StringBuilder();

            Match m;

            List <string> lines = TextParser.GetLines(text);
            int           i     = 0;

            while (i < lines.Count && (m = TextRegex.Match(lines[i])).Success)
            {
                if (i > 0)
                {
                    sb.AppendLine();
                }

                sb.Append(m.Groups[1].Value);

                i++;
            }

            return(new Text(sb));
        }