Beispiel #1
0
        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("???");
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #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());
        }