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 ReversePathWorksWithSingleSegment() { // $expand=1 PathReverser pathReverser = new PathReverser(); PathSegmentToken nonReversedPath = new NonSystemToken("1", null, null); PathSegmentToken reversedPath = nonReversedPath.Accept(pathReverser); reversedPath.ShouldBeNonSystemToken("1").NextToken.Should().BeNull(); }
public void ReversePathWorksWithATypeToken() { // $expand=Fully.Qualified.Namespace/1 PathReverser pathReverser = new PathReverser(); PathSegmentToken nonReversedPath = new NonSystemToken("1", null, new NonSystemToken("Fully.Qualified.Namespace", null, null)); PathSegmentToken reversedPath = nonReversedPath.Accept(pathReverser); reversedPath.ShouldBeNonSystemToken("Fully.Qualified.Namespace").NextToken.ShouldBeNonSystemToken("1"); }
public void ReversePathWorksWithStarToken() { // $expand=1/* PathReverser pathReverser = new PathReverser(); PathSegmentToken nonReversedPath = new NonSystemToken("*", null, new NonSystemToken("1", null, null)); PathSegmentToken reversedPath = nonReversedPath.Accept(pathReverser); reversedPath.ShouldBeNonSystemToken("1").NextToken.ShouldBeNonSystemToken("*"); }
public void ReversePathWorksWithDeepPath() { // $expand=1/2/3/4 PathReverser pathReverser = new PathReverser(); NonSystemToken endPath = new NonSystemToken("4", null, new NonSystemToken("3", null, new NonSystemToken("2", null, new NonSystemToken("1", null, null)))); PathSegmentToken reversedPath = endPath.Accept(pathReverser); reversedPath.ShouldBeNonSystemToken("1") .NextToken.ShouldBeNonSystemToken("2") .NextToken.ShouldBeNonSystemToken("3") .NextToken.ShouldBeNonSystemToken("4"); }
public void ReversePathWorksWithSingleSegment() { // Arrange: $expand=1 PathSegmentToken nonReversedPath = new NonSystemToken("1", null, null); // Act PathSegmentToken reversedPath = nonReversedPath.Reverse(); // Assert NonSystemToken nonSystemToken = reversedPath.ShouldBeNonSystemToken("1"); Assert.Null(nonSystemToken.NextToken); }
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()); }