コード例 #1
0
        public AnalyzedStepText Analyze(string stepText, CultureInfo bindingCulture)
        {
            var result = new AnalyzedStepText();

            var paramMatches = RecognizeQuotedTexts(stepText).Concat(RecognizeIntegers(stepText)).Concat(RecognizeDecimals(stepText, bindingCulture))
                               .OrderBy(m => m.Item1.Index).ThenByDescending(m => m.Item1.Length);

            int textIndex = 0;

            foreach (var paramMatch in paramMatches)
            {
                if (paramMatch.Item1.Index < textIndex)
                {
                    continue;
                }

                string value      = paramMatch.Item1.Value;
                int    index      = paramMatch.Item1.Index;
                string paramValue = paramMatch.Item3;

                result.TextParts.Add(stepText.Substring(textIndex, index - textIndex));
                result.Parameters.Add(AnalyzeParameter(result.Parameters.Count, paramMatch.Item2, paramValue));
                textIndex = index + value.Length;
            }

            result.TextParts.Add(stepText.Substring(textIndex));
            return(result);
        }
コード例 #2
0
        protected override string GetExpression(AnalyzedStepText stepText)
        {
            StringBuilder result = new StringBuilder();

            result.Append(EscapeRegex(stepText.TextParts[0]));
            for (int i = 1; i < stepText.TextParts.Count; i++)
            {
                result.Append(stepText.Parameters[i - 1].RegexPattern);
                result.Append(EscapeRegex(stepText.TextParts[i]));
            }

            return(result.ToString());
        }
コード例 #3
0
        // imported from SpecFlow v2.4

        private static string GetRegex(AnalyzedStepText stepText)
        {
            StringBuilder result = new StringBuilder();

            result.Append(EscapeRegex(stepText.TextParts[0]));
            for (int i = 1; i < stepText.TextParts.Count; i++)
            {
                result.AppendFormat("({0})", stepText.Parameters[i - 1].RegexPattern);
                result.Append(EscapeRegex(stepText.TextParts[i]));
            }

            return(result.ToString());
        }
コード例 #4
0
        public AnalyzedStepText Analyze(string stepText, CultureInfo bindingCulture)
        {
            var result = new AnalyzedStepText();

            var paramMatches = RecognizeQuotedTexts(stepText).Concat(RecognizeIntegers(stepText)).Concat(RecognizeDecimals(stepText, bindingCulture))
                               .OrderBy(m => m.Index).ThenByDescending(m => m.Length);

            int textIndex = 0;

            foreach (var paramMatch in paramMatches)
            {
                if (paramMatch.Index < textIndex)
                {
                    continue;
                }

                const string singleQuoteRegexPattern = "[^']*";
                const string doubleQuoteRegexPattern = "[^\"\"]*";
                const string defaultRegexPattern     = ".*";

                string regexPattern = defaultRegexPattern;
                string value        = paramMatch.Value;
                int    index        = paramMatch.Index;

                if (index > 0)
                {
                    switch (stepText[index - 1])
                    {
                    case '\"':
                        regexPattern = doubleQuoteRegexPattern;
                        break;

                    case '\'':
                        regexPattern = singleQuoteRegexPattern;
                        break;
                    }
                }

                result.TextParts.Add(stepText.Substring(textIndex, index - textIndex));
                result.Parameters.Add(AnalyzeParameter(value, bindingCulture, result.Parameters.Count, regexPattern));
                textIndex = index + value.Length;
            }

            result.TextParts.Add(stepText.Substring(textIndex));
            return(result);
        }
コード例 #5
0
        private static string GetMethodName(UndefinedStepDescriptor stepInstance, AnalyzedStepText analyzedStepText)
        {
            var keyword = stepInstance.ScenarioBlock.ToString(); //TODO: get lang specific keyword

            return(keyword.ToIdentifier() + string.Concat(analyzedStepText.TextParts.ToArray()).ToIdentifier());
        }
コード例 #6
0
 protected abstract string GetExpression(AnalyzedStepText stepText);