public void It_Should_Generate_Snippet_For_Step_With_No_Parameters() { var snippetRequest = new SnippetRequest { Keyword = "Given" , StepName = "this is a step" }; var snippetResponse = processor.Process(snippetRequest) as SnippetResponse; snippetResponse.Should().Not.Be.Null(); (snippetResponse.Snippet).Should().Be.EqualTo("\nGiven(\"^this is a step$\", () => {\n\tPending();\n});"); }
private Response ProcessSnippet(SnippetRequest request) { var argValues = new[] { "string arg1", "string arg2", "string arg3", "string arg4", "string arg5", "string arg6", "string arg7", "string arg8", "string arg9" }; const string assumedArgumentPattern = "\"[^\"]*\""; const string parameterMetaPattern = "\\\"([^\\\"]*)\\\""; var step = request.StepName; var stepKind = request.Keyword; var paramCount = new Regex(assumedArgumentPattern).Matches(step).Count; var paramText = string.Join(", ", argValues, 0, paramCount); if (request.MultilineType == SnippetRequest.MultilineTypes.Table) paramText += (paramCount > 0 ? ", " : "") + "Table table"; var replacedFeatureLine = Regex.Replace(step, assumedArgumentPattern, parameterMetaPattern); var matchedTemplate = string.Format("\n{0}(\"^{1}$\", ({2}) => {{\n\tPending();\n}});", stepKind, replacedFeatureLine, paramText); return new SnippetResponse { Snippet = matchedTemplate }; }
public void It_Should_Generate_Snippet_For_Step_With_String_Parameters_And_Table_Parameter() { var snippetRequest = new SnippetRequest { Keyword = "Given", StepName = "\"this\" is a \"step\"", Multiline = "Cucumber::Ast::Table" }; var snippetResponse = processor.Process(snippetRequest) as SnippetResponse; snippetResponse.Should().Not.Be.Null(); (snippetResponse.Snippet).Should().Be.EqualTo("\nGiven(\"^\\\"([^\\\"]*)\\\" is a \\\"([^\\\"]*)\\\"$\", (string arg1, string arg2, Table table) => {\n\tPending();\n});"); }
public void It_Should_Generate_Snippet_For_Step_With_Table_Parameter() { var snippetRequest = new SnippetRequest { Keyword = "Given", StepName = "this is a step", Multiline = "Cucumber::Ast::Table" }; var snippetResponse = processor.Process(snippetRequest) as SnippetResponse; snippetResponse.Should().Not.Be.Null(); (snippetResponse.Snippet).Should().Be.EqualTo("\nGiven(\"^this is a step$\", (Table table) => {\n\tPending();\n});"); }