예제 #1
0
        public void BindApplyWitMultipleTokensShouldReturnApplyClause()
        {
            IEnumerable <QueryToken> tokens =
                _parser.ParseApply(
                    "groupby((ID, SSN, LifeTime))/aggregate(LifeTime with sum as TotalLife)/groupby((TotalLife))/aggregate(TotalLife with sum as TotalTotalLife)");

            BindingState   state         = new BindingState(_configuration);
            MetadataBinder metadataBiner = new MetadataBinder(_bindingState);

            ApplyBinder binder = new ApplyBinder(metadataBiner.Bind, _bindingState);
            ApplyClause actual = binder.BindApply(tokens);

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

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

            firstGroupBy.Should().NotBeNull();
            TransformationNode firstAggregate = transformations[1] as AggregateTransformationNode;

            firstAggregate.Should().NotBeNull();
            TransformationNode scecondGroupBy = transformations[2] as GroupByTransformationNode;

            scecondGroupBy.Should().NotBeNull();
            AggregateTransformationNode scecondAggregate = transformations[3] as AggregateTransformationNode;

            scecondAggregate.Should().NotBeNull();
        }
예제 #2
0
        public void BindApplyWitGroupByWithAggregateShouldReturnApplyClause()
        {
            IEnumerable <QueryToken> tokens = _parser.ParseApply("groupby((UnitPrice, SalePrice), 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();
            GroupByTransformationNode groupBy         = transformations[0] as GroupByTransformationNode;

            TransformationNode aggregate = groupBy.ChildTransformations;

            aggregate.Should().NotBeNull();
        }