Ejemplo n.º 1
0
        public void CheckAnCorrectInput()
        {
            var sequance = new Sequance(new Character('+'), new Range('0', '9'));

            Assert.True(sequance.Match("+0abc").IsSuccesful());
            Assert.False(sequance.Match("abc").IsSuccesful());
        }
Ejemplo n.º 2
0
        public void CheckForClassText()
        {
            var sequance = new Sequance(new Text("abc"), new Range('0', '9'));

            Assert.True(sequance.Match("abc123").IsSuccesful());
            Assert.Equal("23", sequance.Match("abc123").RemainingText());
        }
Ejemplo n.º 3
0
        public void CheckForFailMatchRemainingText()
        {
            var sequance = new Sequance(new Any("abc"), new Text("12a"));

            Assert.False(sequance.Match("a12bc").IsSuccesful());
            Assert.Equal("a12bc", sequance.Match("a12bc").RemainingText());
        }
Ejemplo n.º 4
0
        public void CheckIfContainJustOneInstance()
        {
            var sequance = new Sequance(new Character('+'), new Range('0', '9'));

            Assert.False(sequance.Match("+abc").IsSuccesful());
            Assert.False(sequance.Match("1abc").IsSuccesful());
        }
Ejemplo n.º 5
0
        public void CheckForAnEmptyString()
        {
            var sequance = new Sequance(new Character('+'), new Range('0', '9'));

            Assert.False(sequance.Match("").IsSuccesful());
            Assert.Equal("", sequance.Match("").RemainingText());
        }
Ejemplo n.º 6
0
        public void CheckForAnEmptyPattern()
        {
            var sequance = new Sequance();

            Assert.True(sequance.Match("1234").IsSuccesful());
            Assert.True(sequance.Match("+abc").IsSuccesful());
            Assert.True(sequance.Match("abcd").IsSuccesful());
        }
Ejemplo n.º 7
0
        public void CheckForASinglePattern()
        {
            var sequance = new Sequance(new Character('+'));

            Assert.True(sequance.Match("+123").IsSuccesful());
            Assert.False(sequance.Match("123").IsSuccesful());
            Assert.Equal("ab", sequance.Match("+ab").RemainingText());
        }
Ejemplo n.º 8
0
        public String()
        {
            IPattern hexadecimal      = new Sequance(new Character('u'), new Many(new Any("123456789ABCDEFabcdef"), 4, 4));
            IPattern controlChar      = new OneOrMore(new Sequance(new Character('\\'), new Choice(new Any("\"\\/bfnrt"), hexadecimal)));
            IPattern unicodeCharacter = new OneOrMore(new Choice(new Range(' ', '!'), new Range('#', '['), new Range(']', Convert.ToChar(65535))));

            stringFormat = new Sequance(new Character('\"'), new Many(new Choice(controlChar, unicodeCharacter)), new Character('\"'));
        }