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); }
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()); }
// 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()); }
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); }
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()); }
protected abstract string GetExpression(AnalyzedStepText stepText);