Exemplo n.º 1
0
        public void UnQuotedValuePatternTest()
        {
            Regex regex = new Regex("^" + Pattern.UnQuotedValuePattern + "$");

            HelperFunction.ShouldMatch(regex, "roger123");
            HelperFunction.ShouldMatch(regex, "_hello");
            HelperFunction.ShouldMatch(regex, "funky_chicken");
            HelperFunction.ShouldMatch(regex, "_1_2_3");
            HelperFunction.ShouldMatch(regex, "Te.St.5_4");
            HelperFunction.ShouldMatch(regex, "\\");
            HelperFunction.ShouldMatch(regex, "C:\\Test");
            HelperFunction.ShouldMatch(regex, "C:\\Test\\");
            HelperFunction.ShouldMatch(regex, "\\\\Domain\\host");
            HelperFunction.ShouldMatch(regex, "Test\\ Directory");
            HelperFunction.ShouldMatch(regex, "@\\\\Domain\\host");
            HelperFunction.ShouldMatch(regex, "@Test\\ Directory");
            HelperFunction.ShouldNotMatch(regex, String.Empty);
            HelperFunction.ShouldNotMatch(regex, " ");
            HelperFunction.ShouldNotMatch(regex, "' '");
            HelperFunction.ShouldNotMatch(regex, "\" \"");
            HelperFunction.ShouldNotMatch(regex, "\\ .ab'");
            HelperFunction.ShouldNotMatch(regex, " ");
            HelperFunction.ShouldNotMatch(regex, "roger ");
            HelperFunction.ShouldNotMatch(regex, " roger");
            HelperFunction.ShouldNotMatch(regex, " roger ");
        }
Exemplo n.º 2
0
        public void DoubleQuotedValuePatternTest()
        {
            Regex regex = new Regex("^" + Pattern.DoubleQuotedValuePattern + "$");

            HelperFunction.ShouldMatch(regex, "\"roger\"");
            HelperFunction.ShouldMatch(regex, "\"_hello\"");
            HelperFunction.ShouldMatch(regex, "\" test test\"");
            HelperFunction.ShouldMatch(regex, "\" foo\\ bar\"");
            HelperFunction.ShouldMatch(regex, "\" foo' bar\"");
            HelperFunction.ShouldMatch(regex, "@\" foo\\ bar\"");
            HelperFunction.ShouldMatch(regex, "@\" foo' bar\"");
            HelperFunction.ShouldNotMatch(regex, "roger");
            HelperFunction.ShouldNotMatch(regex, "_hello");
            HelperFunction.ShouldNotMatch(regex, "' test test");
            HelperFunction.ShouldNotMatch(regex, "' foo\\ bar' '");
        }
Exemplo n.º 3
0
        public void SingleQuotedValuePatternTest()
        {
            Regex regex = new Regex("^" + Pattern.SingleQuotedValuePattern + "$");

            HelperFunction.ShouldMatch(regex, "'roger'");
            HelperFunction.ShouldMatch(regex, "'_hello'");
            HelperFunction.ShouldMatch(regex, "' test test'");
            HelperFunction.ShouldMatch(regex, "' foo\\ bar'");
            HelperFunction.ShouldMatch(regex, "' foo\" bar'");
            HelperFunction.ShouldMatch(regex, "@' foo\\ bar'");
            HelperFunction.ShouldMatch(regex, "@' foo\" bar'");
            HelperFunction.ShouldNotMatch(regex, "roger");
            HelperFunction.ShouldNotMatch(regex, "_hello");
            HelperFunction.ShouldNotMatch(regex, "' test test");
            HelperFunction.ShouldNotMatch(regex, "' foo\\ bar' '");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Test the NamePattern
        /// </summary>
        public void NamePatternTest()
        {
            Regex regex = new Regex("^" + Pattern.NamePattern + "$");

            HelperFunction.ShouldMatch(regex, "roger123");
            HelperFunction.ShouldMatch(regex, "_hello");
            HelperFunction.ShouldMatch(regex, "funky_chicken");
            HelperFunction.ShouldMatch(regex, "_1_2_3");
            HelperFunction.ShouldMatch(regex, "Te.St.5_4");
            HelperFunction.ShouldNotMatch(regex, ".ab");
            HelperFunction.ShouldNotMatch(regex, ".ab");
            HelperFunction.ShouldNotMatch(regex, " ");
            HelperFunction.ShouldNotMatch(regex, "roger ");
            HelperFunction.ShouldNotMatch(regex, " roger");
            HelperFunction.ShouldNotMatch(regex, " roger ");
        }
Exemplo n.º 5
0
        public void ValuePatternTest()
        {
            Regex regex = new Regex("^" + Pattern.ValuePattern + "$");

            // Not quotes
            HelperFunction.ShouldMatch(regex, "roger123");
            HelperFunction.ShouldMatch(regex, "_hello");
            HelperFunction.ShouldMatch(regex, "funky_chicken");
            HelperFunction.ShouldMatch(regex, "_1_2_3");
            HelperFunction.ShouldMatch(regex, "Te.St.5_4");
            HelperFunction.ShouldMatch(regex, "\\");
            HelperFunction.ShouldMatch(regex, "C:\\Test");
            HelperFunction.ShouldMatch(regex, "C:\\Test\\");
            HelperFunction.ShouldMatch(regex, "\\\\Domain\\host");
            HelperFunction.ShouldMatch(regex, "Test\\ Directory");

            // Single quotes
            HelperFunction.ShouldMatch(regex, "'roger'");
            HelperFunction.ShouldMatch(regex, "'_hello'");
            HelperFunction.ShouldMatch(regex, "' test test'");
            HelperFunction.ShouldMatch(regex, "' foo\\ bar'");
            HelperFunction.ShouldMatch(regex, "' foo\" bar'");
            HelperFunction.ShouldMatch(regex, "@' foo\\ bar'");
            HelperFunction.ShouldMatch(regex, "@' foo\" bar'");

            // Double quotes
            HelperFunction.ShouldMatch(regex, "\"roger\"");
            HelperFunction.ShouldMatch(regex, "\"_hello\"");
            HelperFunction.ShouldMatch(regex, "\" test test\"");
            HelperFunction.ShouldMatch(regex, "\" foo\\ bar\"");
            HelperFunction.ShouldMatch(regex, "\" foo' bar\"");
            HelperFunction.ShouldMatch(regex, "@\" foo\\ bar\"");
            HelperFunction.ShouldMatch(regex, "@\" foo' bar\"");

            // Mismatches
            HelperFunction.ShouldNotMatch(regex, "\\ .ab'");
        }