예제 #1
0
        private void CompileRegexes(string text)
        {
            var lm = new LanguageManager();

            string language = TextParser.DiscoverLanguage(text);

            string feature  = lm.GetString(language, "Feature");
            string scenario = lm.GetString(language, "Scenario");
            string given    = lm.GetString(language, "Given");
            string when     = lm.GetString(language, "When");
            string then     = lm.GetString(language, "Then");
            string and      = lm.GetString(language, "And");
            string with     = lm.GetString(language, "With");

            this.featureRegex  = new Regex(string.Format(FeaturePattern, feature), RegexOptions.IgnoreCase);
            this.scenarioRegex = new Regex(string.Format(ScenarioPattern, scenario), RegexOptions.IgnoreCase);
            this.givenRegex    = new Regex(string.Format(StepPattern, given), RegexOptions.IgnoreCase);
            this.whenRegex     = new Regex(string.Format(StepPattern, when), RegexOptions.IgnoreCase);
            this.thenRegex     = new Regex(string.Format(StepPattern, then), RegexOptions.IgnoreCase);
            this.andRegex      = new Regex(string.Format(StepPattern, and), RegexOptions.IgnoreCase);
            this.withRegex     = new Regex(string.Format(StepPattern, with), RegexOptions.IgnoreCase);
        }
예제 #2
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));
        }