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); }
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); }
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); }
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); }
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(); }
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")); }
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); }
public void BindPropertyShouldReturnCorrectPropertyIfFoundForEntity() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "Shoe"); result.Should().BeSameAs(HardCodedTestModel.GetPersonShoeProp()); }
public void BindPropertyShouldReturnNullIfNotFound() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "missing"); result.Should().BeNull(); }
public void BindPropertyShouldBeCaseSensitive() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "shoe"); result.Should().BeNull(); }
public void BindPropertyShouldReturnNullIfNotFound() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "missing", DefaultUriResolver); Assert.Null(result); }
public void BindPropertyShouldReturnNullIfTypeNotStructured() { var result = InnerPathTokenBinder.BindProperty(EdmCoreModel.Instance.GetDecimal(false), "NotStructured", DefaultUriResolver); Assert.Null(result); }
public void BindPropertyShouldBeCaseSensitive() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "shoe", DefaultUriResolver); Assert.Null(result); }
public void BindPropertyShouldReturnCorrectPropertyIfFoundForComplex() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonAddressProp().Type, "MyNeighbors", DefaultUriResolver); Assert.Same(HardCodedTestModel.GetAddressMyNeighborsProperty(), result); }
public void BindPropertyShouldReturnCorrectPropertyIfFoundForEntity() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonTypeReference(), "Shoe", DefaultUriResolver); Assert.Same(HardCodedTestModel.GetPersonShoeProp(), result); }
public void BindPropertyShouldReturnCorrectPropertyIfFoundForComplex() { var result = InnerPathTokenBinder.BindProperty(HardCodedTestModel.GetPersonAddressProp().Type, "MyNeighbors"); result.Should().BeSameAs(HardCodedTestModel.GetAddressMyNeighborsProperty()); }
public void BindPropertyShouldReturnNullIfTypeNotStructured() { var result = InnerPathTokenBinder.BindProperty(EdmCoreModel.Instance.GetDecimal(false), "NotStructured"); result.Should().BeNull(); }