Exemplo n.º 1
0
        public void Match_Everything_But_Whitespace_Wont_Match_WhiteSpace()
        {
            var regex   = @"\w";
            var builder = new FluidRegexBuilder()
                          .MatchAnythingButWhiteSpace(NumberOfTimes.Once);
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsFalse(builtRegex.IsMatch(" "));
        }
Exemplo n.º 2
0
        public void Match_Everything_But_Whitespace_Matches_Non_White_Space()
        {
            var regex   = @"\w";
            var builder = new FluidRegexBuilder()
                          .MatchAnythingButWhiteSpace(NumberOfTimes.Once);
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsTrue(builtRegex.IsMatch("hello"));
            Assert.IsTrue(builtRegex.IsMatch("$$$fadg"));
            Assert.IsTrue(builtRegex.IsMatch("^%$*& adg"));
        }
Exemplo n.º 3
0
        public void Match_The_Charachter_Does_Not_Match_Other_Charatchers()
        {
            var regex   = "@";
            var builder = new FluidRegexBuilder()
                          .MatchTheCharachter(regex);
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsFalse(builtRegex.IsMatch("a"));
            Assert.IsFalse(builtRegex.IsMatch("aaaaaa..dfalkj343"));
            Assert.IsFalse(builtRegex.IsMatch("#^%&$"));
            Assert.IsFalse(builtRegex.IsMatch(" "));
        }
Exemplo n.º 4
0
        public void Match_The_Charachter_Matches_Charatcher()
        {
            var regex   = "@";
            var builder = new FluidRegexBuilder()
                          .MatchTheCharachter(regex);
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsTrue(builtRegex.IsMatch("[email protected]"));
            Assert.IsTrue(builtRegex.IsMatch("a@a@a@"));
            Assert.IsTrue(builtRegex.IsMatch("@@@aadsaf@"));
            Assert.IsTrue(builtRegex.IsMatch("aadsaf@"));
        }
Exemplo n.º 5
0
        public void Match_One_Of_These_Charachters_Fails_On_No_Match_Strings()
        {
            var regex   = "[-+.']";
            var builder = new FluidRegexBuilder()
                          .MatchOneOfTheseCharachters(NumberOfTimes.Once, "-", "+", ".", "'");
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsFalse(builtRegex.IsMatch(" "));
            Assert.IsFalse(builtRegex.IsMatch(" blah blah"));
            Assert.IsFalse(builtRegex.IsMatch("start"));
            Assert.IsFalse(builtRegex.IsMatch("///"));
            Assert.IsFalse(builtRegex.IsMatch("ahhh"));
            Assert.IsFalse(builtRegex.IsMatch("start of the string"));
        }
Exemplo n.º 6
0
        public void Match_One_Of_These_Charachters_Matches_Right_Charatchers()
        {
            var regex   = "[-+.']";
            var builder = new FluidRegexBuilder()
                          .MatchOneOfTheseCharachters(NumberOfTimes.Once, "-", "+", ".", "'");
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsTrue(builtRegex.IsMatch("-"));
            Assert.IsTrue(builtRegex.IsMatch(" blah+blah"));
            Assert.IsTrue(builtRegex.IsMatch("-.start"));
            Assert.IsTrue(builtRegex.IsMatch("..."));
            Assert.IsTrue(builtRegex.IsMatch("'ahhh'"));
            Assert.IsTrue(builtRegex.IsMatch("start of the string..."));
        }
Exemplo n.º 7
0
        public void Match_Start_String_Only_Matches_Start_Of_String()
        {
            var regex   = "^start";
            var builder = new FluidRegexBuilder()
                          .MatchStringStart()
                          .MatchTheCharachter("start");
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsFalse(builtRegex.IsMatch("astart"));
            Assert.IsFalse(builtRegex.IsMatch(" start"));
            Assert.IsFalse(builtRegex.IsMatch("aaaaaastart start"));
            Assert.IsFalse(builtRegex.IsMatch(" "));
            Assert.IsFalse(builtRegex.IsMatch("aaa"));
            Assert.IsTrue(builtRegex.IsMatch("start of the string"));
        }
Exemplo n.º 8
0
        public void Match_One_Of_These_Charachters_Matches_Charachters()
        {
            var regex   = "^[sz]";
            var builder = new FluidRegexBuilder()
                          .MatchStringStart()
                          .MatchOneOfTheseCharachters(NumberOfTimes.Once, "s", "z");
            var builtRegex       = builder.CreateInstance();
            var builtRegexString = builder
                                   .CreateInstanceAsString();

            Assert.AreEqual(regex, builtRegexString);
            Assert.IsFalse(builtRegex.IsMatch("astart"));
            Assert.IsFalse(builtRegex.IsMatch(" start"));
            Assert.IsFalse(builtRegex.IsMatch("aaaaaastart start"));
            Assert.IsFalse(builtRegex.IsMatch(" "));
            Assert.IsFalse(builtRegex.IsMatch("aaa"));
            Assert.IsTrue(builtRegex.IsMatch("start of the string"));
            Assert.IsTrue(builtRegex.IsMatch("ztart of the string"));
        }