Ejemplo n.º 1
0
        public static IList<IFilterDescriptor> Create(string input)
        {
            IList<IFilterDescriptor> result = new List<IFilterDescriptor>();

            FilterParser parser = new FilterParser(input);

            IFilterNode filterNode = parser.Parse();

            if (filterNode == null)
            {
                return result;
            }

            FilterNodeVisitor visitor = new FilterNodeVisitor();

            filterNode.Accept(visitor);

            result.Add(visitor.Result);

            return result;
        }
Ejemplo n.º 2
0
 private IFilterNode Parse(string input)
 {
     FilterParser parser = new FilterParser(input);
     return parser.Parse();
 }
Ejemplo n.º 3
0
        public void AlternativeBasicsParsing()
        {
            // Can work with/without whitespace surrounded
            parser.Parse("prop==1||prop==2");
            parser.Parse("prop==1 || prop==2");

            // Both side must be an expression
            Assert.ThrowsAny <Exception>(() => parser.Parse("different || \"ala\" "));
            Assert.ThrowsAny <Exception>(() => parser.Parse("prop==different || \"ala\" "));
            Assert.ThrowsAny <Exception>(() => parser.Parse("different || prop==\"ala\" "));
        }
Ejemplo n.º 4
0
        public void When_Parsing_Incorrect_Str_Then_Exception_Are_Thrown()
        {
            // ARRAGE
            InitializeFakeObjects();

            // ACTS & ASSERTS
            Assert.Throws <InvalidOperationException>(() => _parser.Parse("invalid$outer(FirstName),inner(LastName)"));
            Assert.Throws <InvalidOperationException>(() => _parser.Parse("select"));
            Assert.Throws <InvalidOperationException>(() => _parser.Parse("select$"));
        }
Ejemplo n.º 5
0
        public void NegationBasicParsing()
        {
            parser.Parse("!(prop==different)");
            parser.Parse("! (prop==different)");

            // Negation must be braced. And there no whitespace is allowed between negation and brace.
            Assert.ThrowsAny <Exception>(() => parser.Parse("!prop==different"));
        }
Ejemplo n.º 6
0
        public void BooleanProperty()
        {
            var result = parser.Parse(" delta==true");

            Assert.Equal("(__EqualityEvaluator:delta==true)", result.SemanticsString);
        }