コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #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"));
        }
コード例 #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);
        }
コード例 #8
0
        public void BindPropertyShouldReturnCorrectPropertyIfFoundForEntity()
        {
            var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "Shoe");

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

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

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

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

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

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

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

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

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

            result.Should().BeNull();
        }