Example #1
0
        public void GetNavigationNodeCreatesCollectionNavigationNodeForManyMultiplicityProperty()
        {
            IEdmNavigationProperty property = HardCodedTestModel.GetDogMyPeopleNavProp();
            SingleEntityNode       parent   = new SingleEntityCastNode(null, HardCodedTestModel.GetDogType());
            BindingState           state    = new BindingState(configuration);
            KeyBinder keyBinder             = new KeyBinder(FakeBindMethods.BindMethodReturningASingleDog);

            var result = InnerPathTokenBinder.GetNavigationNode(property, parent, null, state, keyBinder);

            result.ShouldBeCollectionNavigationNode(property);
        }
Example #2
0
        public void CollectionNavigationPropertyShouldCreateMatchingNode()
        {
            var state  = new BindingState(Configuration);
            var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASingleDog, state);
            var token  = new InnerPathToken("MyPeople", new DummyToken(), null /*namedValues*/);

            var result = binder.BindInnerPathSegment(token);

            Assert.Same(HardCodedTestModel.GetDogsSet().FindNavigationTarget(HardCodedTestModel.GetDogMyPeopleNavProp()),
                        result.ShouldBeCollectionNavigationNode(HardCodedTestModel.GetDogMyPeopleNavProp()).NavigationSource);
        }
Example #3
0
        public void OpenPropertyShouldCreateMatchingNode()
        {
            const string OpenPropertyName = "Emotions";
            var          state            = new BindingState(configuration);
            var          binder           = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASinglePainting, state);
            var          token            = new InnerPathToken(OpenPropertyName, new DummyToken(), null /*namedValues*/);

            var result = binder.BindInnerPathSegment(token);

            result.ShouldBeSingleValueOpenPropertyAccessQueryNode(OpenPropertyName);
        }
Example #4
0
        public void GetNavigationNodeCreatesSingleNavigationNodeForSingleMultiplicityProperty()
        {
            IEdmNavigationProperty property = HardCodedTestModel.GetPersonMyDogNavProp();
            IEdmNavigationSource   navigationSource;
            SingleResourceNode     parent = new SingleResourceCastNode(null, HardCodedTestModel.GetDogType());
            BindingState           state  = new BindingState(Configuration);
            KeyBinder keyBinder           = new KeyBinder(FakeBindMethods.BindMethodReturningASingleDog);

            var result = InnerPathTokenBinder.GetNavigationNode(property, parent, null, state, keyBinder, out navigationSource);

            result.ShouldBeSingleNavigationNode(property);
        }
Example #5
0
        public void KeyLookupOnNavPropIntegrationTest()
        {
            var state = new BindingState(Configuration);

            state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(HardCodedTestModel.GetDogTypeReference(), HardCodedTestModel.GetDogsSet());
            var metadataBinder = new MetadataBinder(state);
            var binder         = new InnerPathTokenBinder(metadataBinder.Bind, state);
            var token          = new InnerPathToken("MyPeople", null, new[] { new NamedValue(null, new LiteralToken(123)) });

            var result = binder.BindInnerPathSegment(token);

            result.ShouldBeKeyLookupQueryNode();
        }
Example #6
0
        public void InnerPathTokenBinderShouldFailIfPropertySourceIsNotASingleValue()
        {
            var state = new BindingState(Configuration);

            state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(HardCodedTestModel.GetDogTypeReference(), HardCodedTestModel.GetDogsSet());
            var metadataBinder = new MetadataBinder(state);
            var binder         = new InnerPathTokenBinder(metadataBinder.Bind, state);
            var token          = new InnerPathToken("MyDog", new InnerPathToken("MyPeople", null, null), null);

            Action bind = () => binder.BindInnerPathSegment(token);

            bind.Throws <ODataException>(Strings.MetadataBinder_PropertyAccessSourceNotSingleValue("MyDog"));
        }
Example #7
0
        public void MissingPropertyShouldThrow()
        {
            const string MissingPropertyName = "ThisPropertyDoesNotExist";
            var          state  = new BindingState(Configuration);
            var          binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASingleDog, state);
            var          token  = new InnerPathToken(MissingPropertyName, new DummyToken(), null /*namedValues*/);

            Action bind = () => binder.BindInnerPathSegment(token);

            string expectedMessage =
                ODataErrorStrings.MetadataBinder_PropertyNotDeclared(HardCodedTestModel.GetDogType().FullTypeName(), MissingPropertyName);

            bind.Throws <ODataException>(expectedMessage);
        }
Example #8
0
        public void BindPropertyShouldReturnCorrectPropertyIfFoundForEntity()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "Shoe");

            result.Should().BeSameAs(HardCodedTestModel.GetPersonShoeProp());
        }
Example #9
0
        public void BindPropertyShouldReturnNullIfNotFound()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "missing");

            result.Should().BeNull();
        }
Example #10
0
        public void BindPropertyShouldBeCaseSensitive()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "shoe");

            result.Should().BeNull();
        }
Example #11
0
        public void BindPropertyShouldReturnNullIfNotFound()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "missing", DefaultUriResolver);

            Assert.Null(result);
        }
Example #12
0
        public void BindPropertyShouldReturnNullIfTypeNotStructured()
        {
            var result = InnerPathTokenBinder.BindProperty(EdmCoreModel.Instance.GetDecimal(false), "NotStructured", DefaultUriResolver);

            Assert.Null(result);
        }
Example #13
0
        public void BindPropertyShouldBeCaseSensitive()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "shoe", DefaultUriResolver);

            Assert.Null(result);
        }
Example #14
0
        public void BindPropertyShouldReturnCorrectPropertyIfFoundForComplex()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonAddressProp().Type, "MyNeighbors", DefaultUriResolver);

            Assert.Same(HardCodedTestModel.GetAddressMyNeighborsProperty(), result);
        }
Example #15
0
        public void BindPropertyShouldReturnCorrectPropertyIfFoundForEntity()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "Shoe", DefaultUriResolver);

            Assert.Same(HardCodedTestModel.GetPersonShoeProp(), result);
        }
Example #16
0
        public void BindPropertyShouldReturnCorrectPropertyIfFoundForComplex()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonAddressProp().Type, "MyNeighbors");

            result.Should().BeSameAs(HardCodedTestModel.GetAddressMyNeighborsProperty());
        }
Example #17
0
        public void BindPropertyShouldReturnNullIfTypeNotStructured()
        {
            var result = InnerPathTokenBinder.BindProperty(EdmCoreModel.Instance.GetDecimal(false), "NotStructured");

            result.Should().BeNull();
        }