protected void ParseAndAssert <TRet>(string expr, Expression <Func <Dummy, TRet> > expected)
        {
            var actual = this.parser.Parse(typeof(Dummy), expr);

            Console.WriteLine("{0} => {1}", expr, actual);
            var evaluateClosureMemberVisitor = new EvaluateClosureMemberVisitor();

            expected = (Expression <Func <Dummy, TRet> >)evaluateClosureMemberVisitor.Visit(expected);
            AssertExpressionEquals(actual, expected);
        }
Пример #2
0
        public void Parse_ConstantArrayOfEnumValuesContains_CreatesCorrectExpression()
        {
            var expr = this.parser.Parse <Dummy>("AnEnumValue in ['Moo','Foo']");

            // TODO: Array of constants should be a ConstantExpression maybe? [KNS]
            var testEnums = new[] { TestEnum.Moo, TestEnum.Foo };
            var evaluateClosureVisitor = new EvaluateClosureMemberVisitor();
            Expression <Func <Dummy, bool> > expected = _this => testEnums.Contains(_this.AnEnumValue);

            // We need to evaluate closure display class field accesses to get the same expression
            expected = (Expression <Func <Dummy, bool> >)evaluateClosureVisitor.Visit(expected);
            AssertExpressionEquals(expr, expected);
        }
Пример #3
0
        public void Parse_ConstantArrayOfSimpleValuesContains_CreatesCorrectExpression()
        {
            var expr = this.parser.Parse <Dummy>("Number in [3,2,4]");

            // TODO: Array of constants should be a ConstantExpression maybe? [KNS]
            var ints = new[] { 3, 2, 4 };
            var evaluateClosureVisitor = new EvaluateClosureMemberVisitor();
            Expression <Func <Dummy, bool> > expected = _this => ints.Contains(_this.Number);

            // We need to evaluate closure display class field accesses to get the same expression
            expected = (Expression <Func <Dummy, bool> >)evaluateClosureVisitor.Visit(expected);
            AssertExpressionEquals(expr, expected);
        }