Exemplo n.º 1
0
        public void WildcardDoesNotPreemptOtherSelectionItems()
        {
            ODataSelectPath coolPeoplePath = new ODataSelectPath(new OperationSegment(new[] { HardCodedTestModel.GetChangeStateAction() }, null));
            ODataSelectPath stuffPath      = new ODataSelectPath(new DynamicPathSegment("stuff"));
            var             expandTree     = new SelectExpandClause(new Collection <SelectItem>()
            {
                new PathSelectItem(coolPeoplePath),
                new PathSelectItem(new ODataSelectPath(new NavigationPropertySegment(HardCodedTestModel.GetPaintingOwnerNavProp(), null))),
                new PathSelectItem(stuffPath),
                new PathSelectItem(new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPaintingColorsProperty())))
            }, false);
            var binder      = new SelectBinder(HardCodedTestModel.TestModel, HardCodedTestModel.GetPaintingType(), 800, expandTree, DefaultUriResolver, null);
            var selectToken = new SelectToken(new List <PathSegmentToken>()
            {
                new NonSystemToken("*", null, null)
            });
            var item = binder.Bind(selectToken);

            item.SelectedItems.Should().HaveCount(4)
            .And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath == coolPeoplePath)
            .And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath == stuffPath)
            .And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath.LastSegment is NavigationPropertySegment && x.As <PathSelectItem>().SelectedPath.LastSegment.As <NavigationPropertySegment>().NavigationProperty.Name == HardCodedTestModel.GetPaintingOwnerNavProp().Name)
            .And.Contain(x => x is WildcardSelectItem);
        }