public void ExpandedNavigationPropertiesAreNotAddedAsPathSelectionItemsIfSelectIsNotPopulated() { SelectExpandClause clause = new SelectExpandClause(new SelectItem[] { new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(ModelBuildingHelpers.BuildValidNavigationProperty(), ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List <SelectItem>(), false)), }, false /*allSelected*/); SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause); clause.SelectedItems.Should().HaveCount(1); }
public void ExpandedNavigationPropertiesAreImplicitlyAddedAsPathSelectionItemsIfSelectIsPopulated() { IEdmNavigationProperty navigationProperty = ModelBuildingHelpers.BuildValidNavigationProperty(); SelectExpandClause clause = new SelectExpandClause(new SelectItem[] { new PathSelectItem(new ODataSelectPath(new PropertySegment(ModelBuildingHelpers.BuildValidPrimitiveProperty()))), new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(navigationProperty, ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List <SelectItem>(), false)), }, false /*allSelected*/); SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause); clause.SelectedItems.Should().HaveCount(3) .And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath.LastSegment is NavigationPropertySegment && x.As <PathSelectItem>().SelectedPath.LastSegment.As <NavigationPropertySegment>().NavigationProperty.Name == navigationProperty.Name); }
public void ExpandedNavigationPropertiesAreImplicitlyAddedAsPathSelectionItemsIfSelectIsPopulated() { IEdmNavigationProperty navigationProperty = ModelBuildingHelpers.BuildValidNavigationProperty(); IEdmStructuralProperty structuralProperty = ModelBuildingHelpers.BuildValidPrimitiveProperty(); SelectExpandClause clause = new SelectExpandClause(new SelectItem[] { new PathSelectItem(new ODataSelectPath(new PropertySegment(structuralProperty))), new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(navigationProperty, ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List <SelectItem>(), false)), }, false /*allSelected*/); SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause); Assert.Equal(2, clause.SelectedItems.Count()); var pathSelectItem = Assert.IsType <PathSelectItem>(Assert.Single(clause.SelectedItems, x => x is PathSelectItem)); var propertySegment = Assert.IsType <PropertySegment>(pathSelectItem.SelectedPath.LastSegment); Assert.Equal(structuralProperty.Name, propertySegment.Property.Name); }