Exemplo n.º 1
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);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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.Throws <ODataException>(Strings.MetadataBinder_LambdaParentMustBeCollection);
        }
Exemplo n.º 4
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.Throws <ODataException>(Strings.MetadataBinder_AnyAllExpressionNotSingleValue);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }