Esempio n. 1
0
        /// <summary>
        /// Binds a LambdaToken.
        /// </summary>
        /// <param name="lambdaToken">The LambdaToken to bind.</param>
        /// <returns>A bound Any or All node.</returns>
        protected virtual QueryNode BindAnyAll(LambdaToken lambdaToken)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");

            LambdaBinder binder = new LambdaBinder(this.Bind);

            return(binder.BindLambdaToken(lambdaToken, this.BindingState));
        }
Esempio n. 2
0
        public void AnyTokenWithEntityCollectionParentConstantExpression()
        {
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
            var anyToken = this.CreateTestAnyQueryToken();

            var result = binder.BindLambdaToken(anyToken, state);
            result.ShouldBeAnyQueryNode().And.Source.ShouldBeEntitySetQueryNode(HardCodedTestModel.GetPeopleSet());
            result.Body.ShouldBeConstantQueryNode(true);
        }
Esempio n. 3
0
        public void AllTokenWithNonEntityCollectionParentNonConstantExpression()
        {
            this.parentQueryNode = new CollectionPropertyAccessNode(new ConstantNode(null), HardCodedTestModel.GetDogNicknamesProperty());
            this.expressionQueryNode = new BinaryOperatorNode(BinaryOperatorKind.LessThanOrEqual, new ConstantNode(1), new ConstantNode(5));
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
            var allToken = this.CreateTestAllQueryToken();

            var result = binder.BindLambdaToken(allToken, state);
            result.ShouldBeAllQueryNode().And.Source.ShouldBeCollectionPropertyAccessQueryNode(HardCodedTestModel.GetDogNicknamesProperty());
            result.Body.ShouldBeBinaryOperatorNode(BinaryOperatorKind.LessThanOrEqual);
        }
Esempio n. 4
0
        public void AnyTokenWithNonConstantExpressionNullParameter()
        {
            this.expressionQueryNode = new UnaryOperatorNode(UnaryOperatorKind.Negate, new ConstantNode(false));
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
            var expression = new LiteralToken("foo");
            var parent = new LiteralToken("bar");
            var anyToken = new AnyToken(expression, null, parent);

            var result = binder.BindLambdaToken(anyToken, state);
            result.ShouldBeAnyQueryNode().And.Source.ShouldBeEntitySetQueryNode(HardCodedTestModel.GetPeopleSet());
            result.Body.ShouldBeUnaryOperatorNode(UnaryOperatorKind.Negate);
        }
Esempio n. 5
0
        public void BindLambdaTokenShouldFailForNonCollectionParent()
        {
            this.parentQueryNode = new ConstantNode(true);
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
            var allToken = this.CreateTestAllQueryToken();

            Action bind = () => binder.BindLambdaToken(allToken, state);
            bind.ShouldThrow<ODataException>().
                WithMessage((Strings.MetadataBinder_LambdaParentMustBeCollection));
        }
Esempio n. 6
0
        public void BindLambdaTokenShouldFailForNonBoolExpression()
        {
            this.expressionQueryNode = new ConstantNode(0);
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
            var allToken = this.CreateTestAnyQueryToken();

            Action bind = () => binder.BindLambdaToken(allToken, state);
            bind.ShouldThrow<ODataException>().
                WithMessage((Strings.MetadataBinder_AnyAllExpressionNotSingleValue));
        }
Esempio n. 7
0
        public void BindLambdaTokenShouldPassForOpenPropertyParent()
        {
            this.parentQueryNode = new CollectionOpenPropertyAccessNode(new ConstantNode(null), "SomeCollectionProperty");
            var binder = new LambdaBinder(this.FakeBindMethod);
            var state = this.GetBindingStateForTest(HardCodedTestModel.GetPaintingTypeReference(), HardCodedTestModel.GetPaintingsSet());
            var allToken = this.CreateTestAllQueryToken();

            Action bind = () => binder.BindLambdaToken(allToken, state);
            bind.ShouldNotThrow();
        }
Esempio n. 8
0
        /// <summary>
        /// Binds a LambdaToken.
        /// </summary>
        /// <param name="lambdaToken">The LambdaToken to bind.</param>
        /// <returns>A bound Any or All node.</returns>
        protected virtual QueryNode BindAnyAll(LambdaToken lambdaToken)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");

            LambdaBinder binder = new LambdaBinder(this.Bind);
            return binder.BindLambdaToken(lambdaToken, this.BindingState);
        }