コード例 #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()));
        }
コード例 #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));
        }
コード例 #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()));
        }
コード例 #4
0
        public void Should_handle_dot_star()
        {
            var result = RegexSampler.GetRegexSample(@".*", new string[0]);

            StringAssert.StartsWith(@".*", result);
        }
コード例 #5
0
        public void Should_handle_plus_for_chars()
        {
            var result = RegexSampler.GetRegexSample(@"bla +foo (.*) bar", new[] { "p1" });

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

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

            StringAssert.EndsWith(" foo <p1> bar", result);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }