private string GetSuggestionText(IStepDefinitionBinding stepBinding) { string suggestionTextBase = stepBinding.Regex == null ? "[...]" : "[" + RegexSampler.GetRegexSample(stepBinding.Regex.ToString(), stepBinding.Method.Parameters.Select(p => p.ParameterName).ToArray()) + "]"; return(string.Format("{0} -> {1}", suggestionTextBase, stepBinding.Method.GetShortDisplayText())); }
private string GetRecommendedStepText(string regexAttrValue, CodeFunction codeFunction) { string unmaskAttributeValue = UnmaskAttributeValue(regexAttrValue); var parameters = codeFunction.Parameters.Cast <CodeParameter>().Select(p => p.Name).ToArray(); return(RegexSampler.GetRegexSample(unmaskAttributeValue, parameters)); }
private string GetInsertionText(IStepDefinitionBinding stepBinding) { if (stepBinding.Regex == null) { return("..."); } var paramNames = stepBinding.Method.Parameters.Select(p => p.ParameterName); return(RegexSampler.GetRegexSample(stepBinding.Regex.ToString(), paramNames.ToArray())); }
public void Should_handle_dot_star() { var result = RegexSampler.GetRegexSample(@".*", new string[0]); StringAssert.StartsWith(@".*", result); }
public void Should_handle_plus_for_chars() { var result = RegexSampler.GetRegexSample(@"bla +foo (.*) bar", new[] { "p1" }); StringAssert.StartsWith("bla foo", result); }
public void Should_handle_star_for_gorups() { var result = RegexSampler.GetRegexSample(@"bla (?:hello )*foo (.*) bar", new[] { "p1" }); StringAssert.StartsWith("bla foo", result); }
public void Should_handle_complex_case() { var result = RegexSampler.GetRegexSample(@"a card for an? ((?:actor-goal)|(?:user story)|(?:business goal)) '([^']*)' on the workspace", new[] { "requirementType", "key" }); Assert.AreEqual("a card for a <requirementType> '<key>' on the workspace", result); }
public void Should_handle_non_capturing_gorups() { var result = RegexSampler.GetRegexSample(@"bla (?:.*) foo (.*) bar", new[] { "p1" }); StringAssert.EndsWith(" foo <p1> bar", result); }
public void Should_handle_nested_gorups() { var result = RegexSampler.GetRegexSample(@"bla (a(.*)b) foo (.*) bar", new[] { "p1", "p2" }); Assert.AreEqual("bla <p1> foo <p2> bar", result); }
public void Should_handle_invalid_param_count() { var result = RegexSampler.GetRegexSample(@"bla (.*) foo (.*) bar", new[] { "p1" }); Assert.AreEqual("bla <p1> foo <param> bar", result); }
public void Should_substitute_param_names() { var result = RegexSampler.GetRegexSample(@"bla (.*) foo (.*) bar", new[] { "p1", "p2" }); Assert.AreEqual("bla <p1> foo <p2> bar", result); }
public void Should_handle_param_inside_non_capturing_gorups() { var result = RegexSampler.GetRegexSample(@"bla (?:x(.*)y) foo", new[] { "p1" }); Assert.AreEqual("bla x<p1>y foo", result); }