Exemplo n.º 1
0
        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()));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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()));
        }
Exemplo n.º 4
0
        public void Should_handle_dot_star()
        {
            var result = RegexSampler.GetRegexSample(@".*", new string[0]);

            StringAssert.StartsWith(@".*", result);
        }
Exemplo n.º 5
0
        public void Should_handle_plus_for_chars()
        {
            var result = RegexSampler.GetRegexSample(@"bla +foo (.*) bar", new[] { "p1" });

            StringAssert.StartsWith("bla foo", result);
        }
Exemplo n.º 6
0
        public void Should_handle_star_for_gorups()
        {
            var result = RegexSampler.GetRegexSample(@"bla (?:hello )*foo (.*) bar", new[] { "p1" });

            StringAssert.StartsWith("bla foo", result);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public void Should_handle_non_capturing_gorups()
        {
            var result = RegexSampler.GetRegexSample(@"bla (?:.*) foo (.*) bar", new[] { "p1" });

            StringAssert.EndsWith(" foo <p1> bar", result);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public void Should_handle_invalid_param_count()
        {
            var result = RegexSampler.GetRegexSample(@"bla (.*) foo (.*) bar", new[] { "p1" });

            Assert.AreEqual("bla <p1> foo <param> bar", result);
        }
Exemplo n.º 11
0
        public void Should_substitute_param_names()
        {
            var result = RegexSampler.GetRegexSample(@"bla (.*) foo (.*) bar", new[] { "p1", "p2" });

            Assert.AreEqual("bla <p1> foo <p2> bar", result);
        }
Exemplo n.º 12
0
        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);
        }