private static AnalyzedStepText Analyze(UndefinedStepDescriptor stepInstance, CultureInfo bindingCulture) { var stepTextAnalyzer = new StepTextAnalyzer(); var result = stepTextAnalyzer.Analyze(stepInstance.StepText, bindingCulture); if (stepInstance.HasDocString) { result.Parameters.Add(new AnalyzedStepParameter("String", "multilineText")); } if (stepInstance.HasDataTable) { result.Parameters.Add(new AnalyzedStepParameter("Table", "table")); } return(result); }
public string GetStepDefinitionSkeletonSnippet(UndefinedStepDescriptor undefinedStep, string indent = " ", string newLine = null) { try { var configuration = _projectScope.GetDeveroomConfiguration(); newLine = newLine ?? Environment.NewLine; var result = FallbackStepDefinitionSkeletonProvider.GetStepDefinitionSkeletonSnippetFallback(undefinedStep, indent, newLine, configuration.BindingCulture); _logger.LogInfo($"Step definition snippet generated for step '{undefinedStep.StepText}': {Environment.NewLine}{result}"); return(result); } catch (Exception e) { _projectScope.IdeScope.Actions.ShowError("Could not generate step definition snippet.", e); return("???"); } }
public static string GetStepDefinitionSkeletonSnippetFallback(UndefinedStepDescriptor undefinedStep, string indent, string newLine, string bindingCultureName) { var bindingCulture = CultureInfo.GetCultureInfo(bindingCultureName); var analyzedStepText = Analyze(undefinedStep, bindingCulture); var regex = GetRegex(analyzedStepText); var methodName = GetMethodName(undefinedStep, analyzedStepText); var parameters = string.Join(", ", analyzedStepText.Parameters.Select(p => ToDeclaration(p)).ToArray()); var method = $"[{undefinedStep.ScenarioBlock}(@\"{regex}\")]" + newLine + $"public void {methodName}({parameters})" + newLine + $"{{" + newLine + $"{indent}throw new PendingStepException();" + newLine + $"}}" + newLine; return(method); }
public string GetStepDefinitionSkeletonSnippet(UndefinedStepDescriptor undefinedStep, string indent, string newLine, string bindingCultureName) { var bindingCulture = CultureInfo.GetCultureInfo(bindingCultureName); var analyzedStepText = Analyze(undefinedStep, bindingCulture); var regex = GetExpression(analyzedStepText); var methodName = GetMethodName(undefinedStep, analyzedStepText); var parameters = string.Join(", ", analyzedStepText.Parameters.Select(ToDeclaration)); var stringPrefix = UseVerbatimStringForExpression ? "@" : ""; var method = $"[{undefinedStep.ScenarioBlock}({stringPrefix}\"{regex}\")]" + newLine + $"public void {methodName}({parameters})" + newLine + $"{{" + newLine + $"{indent}throw new PendingStepException();" + newLine + $"}}" + newLine; return(method); }
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()); }