public void NormalizeTreeWorksForMultipleTerms()
        {
            // Arrange: $select=1/2/3,4/5/6
            NonSystemToken endPath1 = new NonSystemToken("3", null, new NonSystemToken("2", null, new NonSystemToken("1", null, null)));

            Assert.Equal("3/2/1", endPath1.ToPathString());

            NonSystemToken endPath2 = new NonSystemToken("6", null, new NonSystemToken("5", null, new NonSystemToken("4", null, null)));

            Assert.Equal("6/5/4", endPath2.ToPathString());

            // Act
            SelectToken selectToken = new SelectToken(new SelectTermToken[]
            {
                new SelectTermToken(endPath1), new SelectTermToken(endPath2)
            });
            SelectToken normalizedToken = SelectTreeNormalizer.NormalizeSelectTree(selectToken);

            // Assert
            List <PathSegmentToken> tokens = normalizedToken.Properties.ToList();

            Assert.Equal(2, tokens.Count);

            tokens[0].ShouldBeNonSystemToken("1")
            .NextToken.ShouldBeNonSystemToken("2")
            .NextToken.ShouldBeNonSystemToken("3");
            Assert.Equal("1/2/3", tokens[0].ToPathString());

            tokens[1].ShouldBeNonSystemToken("4")
            .NextToken.ShouldBeNonSystemToken("5")
            .NextToken.ShouldBeNonSystemToken("6");
            Assert.Equal("4/5/6", tokens[1].ToPathString());
        }
        public void NormalizeTreeResultsInReversedPath()
        {
            // Arrange: $select=1/2/3
            NonSystemToken endPath = new NonSystemToken("3", null, new NonSystemToken("2", null, new NonSystemToken("1", null, null)));

            Assert.Equal("3/2/1", endPath.ToPathString());

            SelectToken selectToken = new SelectToken(new SelectTermToken[]
            {
                new SelectTermToken(endPath)
            });

            // Act
            SelectToken normalizedToken = SelectTreeNormalizer.NormalizeSelectTree(selectToken);

            // Assert
            Assert.NotNull(normalizedToken);
            SelectTermToken  updatedSegmentToken = Assert.Single(normalizedToken.SelectTerms);
            PathSegmentToken segmentToken        = updatedSegmentToken.PathToProperty;

            segmentToken.ShouldBeNonSystemToken("1")
            .NextToken.ShouldBeNonSystemToken("2")
            .NextToken.ShouldBeNonSystemToken("3");

            Assert.Equal("1/2/3", segmentToken.ToPathString());
        }
        public void ReversePathWorksWithATypeToken()
        {
            // Arrange: $expand=Fully.Qualified.Namespace/1
            PathSegmentToken nonReversedPath = new NonSystemToken("1", null, new NonSystemToken("Fully.Qualified.Namespace", null, null));

            Assert.Equal("1/Fully.Qualified.Namespace", nonReversedPath.ToPathString());

            // Act
            PathSegmentToken reversedPath = nonReversedPath.Reverse();

            // Assert
            reversedPath.ShouldBeNonSystemToken("Fully.Qualified.Namespace").NextToken.ShouldBeNonSystemToken("1");
            Assert.Equal("Fully.Qualified.Namespace/1", reversedPath.ToPathString());
        }
        public void ReversePathWorksWithStarToken()
        {
            // Arrange: $expand=1/*
            PathSegmentToken nonReversedPath = new NonSystemToken("*", null, new NonSystemToken("1", null, null));

            Assert.Equal("*/1", nonReversedPath.ToPathString());

            // Act
            PathSegmentToken reversedPath = nonReversedPath.Reverse();

            // Assert
            reversedPath.ShouldBeNonSystemToken("1").NextToken.ShouldBeNonSystemToken("*");
            Assert.Equal("1/*", reversedPath.ToPathString());
        }
        public void ReversePathWorksWithDeepPath()
        {
            // Arrange: $expand=1/2/3/4
            NonSystemToken endPath = new NonSystemToken("4", null, new NonSystemToken("3", null, new NonSystemToken("2", null, new NonSystemToken("1", null, null))));

            Assert.Equal("4/3/2/1", endPath.ToPathString());

            // Act
            PathSegmentToken reversedPath = endPath.Reverse();

            // Assert
            reversedPath.ShouldBeNonSystemToken("1")
            .NextToken.ShouldBeNonSystemToken("2")
            .NextToken.ShouldBeNonSystemToken("3")
            .NextToken.ShouldBeNonSystemToken("4");
            Assert.Equal("1/2/3/4", reversedPath.ToPathString());
        }