Beispiel #1
0
        public void BindApplyWithAggregateShouldReturnApplyClause()
        {
            IEnumerable <QueryToken> tokens = _parser.ParseApply("aggregate(UnitPrice with sum as TotalPrice)");

            ApplyBinder binder = new ApplyBinder(FakeBindMethods.BindSingleComplexProperty, _bindingState);
            ApplyClause actual = binder.BindApply(tokens);

            actual.Should().NotBeNull();
            actual.Transformations.Should().HaveCount(1);

            List <TransformationNode>   transformations = actual.Transformations.ToList();
            AggregateTransformationNode aggregate       = transformations[0] as AggregateTransformationNode;

            aggregate.Should().NotBeNull();
            aggregate.Kind.Should().Be(TransformationNodeKind.Aggregate);
            aggregate.AggregateExpressions.Should().NotBeNull();
            aggregate.AggregateExpressions.Should().HaveCount(1);

            List <AggregateExpressionBase> statements = aggregate.AggregateExpressions.ToList();
            AggregateExpression            statement  = statements[0] as AggregateExpression;

            statement.Should().NotBeNull();
            VerifyIsFakeSingleValueNode(statement.Expression);
            statement.Method.Should().Be(AggregationMethod.Sum);
            statement.Alias.Should().Be("TotalPrice");
        }