public void NestedGroupbyTransformationsIsAllowed() { var result = this.ParseExpandOptions("($apply=groupby((Customer/CountryRegion,Product/Name),aggregate(Amount with sum as Total)))"); result.Should().NotBeNull(); QueryToken token = result.ApplyOptions.Single(); token.Should().BeOfType <GroupByToken>(); GroupByToken groupBy = token as GroupByToken; groupBy.Properties.Should().HaveCount(2); QueryToken queryToken = groupBy.Properties.ElementAt(0); EndPathToken pathToken = queryToken.ShouldBeEndPathToken("CountryRegion"); pathToken.NextToken.ShouldBeInnerPathToken("Customer"); queryToken = groupBy.Properties.ElementAt(1); pathToken = queryToken.ShouldBeEndPathToken("Name"); pathToken.NextToken.ShouldBeInnerPathToken("Product"); groupBy.Child.Should().NotBeNull(); groupBy.Child.Should().BeOfType <AggregateToken>(); AggregateToken aggregate = groupBy.Child as AggregateToken; AggregateExpressionToken aggregateExpressionToken = aggregate.Expressions.Single(); aggregateExpressionToken.Alias.Should().Equals("Total"); aggregateExpressionToken.Method.Should().Equals(AggregationMethod.Sum); aggregateExpressionToken.Expression.ShouldBeEndPathToken("Amount"); }
public void NestedGroupbyTransformationsInExpandIsAllowed() { // Arrange & Act ExpandTermToken expandTerm = this.ParseExpandOptions("($apply=groupby((Customer/CountryRegion,Product/Name),aggregate(Amount with sum as Total)))"); // Assert Assert.NotNull(expandTerm); Assert.NotNull(expandTerm.ApplyOptions); QueryToken token = Assert.Single(expandTerm.ApplyOptions); GroupByToken groupBy = Assert.IsType <GroupByToken>(token); Assert.Equal(2, groupBy.Properties.Count()); QueryToken queryToken = groupBy.Properties.ElementAt(0); EndPathToken pathToken = queryToken.ShouldBeEndPathToken("CountryRegion"); pathToken.NextToken.ShouldBeInnerPathToken("Customer"); queryToken = groupBy.Properties.ElementAt(1); pathToken = queryToken.ShouldBeEndPathToken("Name"); pathToken.NextToken.ShouldBeInnerPathToken("Product"); Assert.NotNull(groupBy.Child); AggregateToken aggregate = Assert.IsType <AggregateToken>(groupBy.Child); AggregateExpressionToken aggregateExpressionToken = Assert.Single(aggregate.Expressions); Assert.Equal("Total", aggregateExpressionToken.Alias); Assert.Equal(AggregationMethod.Sum, aggregateExpressionToken.Method); aggregateExpressionToken.Expression.ShouldBeEndPathToken("Amount"); }
public void MemberAccessParsedCorrectly() { var tokenizer = this.GetIdentifierTokenizerWithRealFunctionParser("stuff"); QueryToken result = tokenizer.ParseIdentifier(null); result.ShouldBeEndPathToken("stuff"); }
public void MemberAccessWithIdentifierReturnsPropertyAccessToken() { var tokenizer = this.GetIdentifierTokenizerWithRealFunctionParser("stuff"); RangeVariableToken rangeVariableToken = new RangeVariableToken(ExpressionConstants.It); QueryToken result = tokenizer.ParseMemberAccess(rangeVariableToken); result.ShouldBeEndPathToken("stuff").And.NextToken.As <RangeVariableToken>().Name.Should().Be(ExpressionConstants.It); }
public void MemberAccessWithIdentifierReturnsPropertyAccessToken() { var tokenizer = this.GetIdentifierTokenizerWithRealFunctionParser("stuff"); RangeVariableToken rangeVariableToken = new RangeVariableToken(ExpressionConstants.It); QueryToken result = tokenizer.ParseMemberAccess(rangeVariableToken); var rangeToken = Assert.IsType <RangeVariableToken>(result.ShouldBeEndPathToken("stuff").NextToken); Assert.Equal(ExpressionConstants.It, rangeToken.Name); }