public async Task ShouldAggregateByChannelWithTermsAggregator()
        {
            /// Arrange
            var channelId = "rootChannel";
            var request   = new ContentAggregationRequest
            {
                SearchString = string.Empty,
                Aggregators  = new List <AggregatorBase>
                {
                    new TermsAggregator {
                        Name = "Permissions", Field = "permissionSetIds", Size = 10
                    }
                }
            };

            /// Act
            var result = await _client.Contents.AggregateByChannelAsync(channelId, request);

            /// Assert
            var permissionSetResults = result.AggregationResults
                                       .SingleOrDefault(i => i.Name == "Permissions");

            Assert.NotNull(permissionSetResults);
            Assert.True(permissionSetResults.AggregationResultItems.Count > 0);
        }
        public async Task ShouldAggregateWithoutAggregators()
        {
            // Todo: does not find anything
            // Check: does Aggregate() without Aggregators make any sense?
            //// TODO: Must be extended and asserted with useful data.

            var request = new ContentAggregationRequest()
            {
                SearchString = "*"
            };
            ObjectAggregationResult result = await _client.Contents.AggregateAsync(request);

            var numRangeFilter = new NumericRangeFilter()
            {
                Field = "ContentType", Range = new NumericRange {
                    From = 2, To = 5
                }
            };

            request.Filter = numRangeFilter;
            result         = await _client.Contents.AggregateAsync(request);

            request.Filter          = null;
            request.LifeCycleFilter = LifeCycleFilter.All;
            result = await _client.Contents.AggregateAsync(request);

            request.Aggregators = new List <AggregatorBase>();
            result = await _client.Contents.AggregateAsync(request);
        }
        public async Task ShouldAggregateByChannel()
        {
            /// Arrange
            var channelId = "rootChannel";
            var request   = new ContentAggregationRequest
            {
                SearchString = string.Empty
            };

            /// Act
            var result = await _client.Contents.AggregateByChannelAsync(channelId, request);

            /// Assert
            var originalWidthResults = result.AggregationResults
                                       .SingleOrDefault(i => i.Name == "Original Width");

            Assert.NotNull(originalWidthResults);
            Assert.True(originalWidthResults.AggregationResultItems.Count > 0);
        }
        public async Task ShouldAggregateWithAggregators()
        {
            var request = new ContentAggregationRequest
            {
                SearchString = string.Empty,
                Aggregators  = new List <AggregatorBase>
                {
                    new TermsAggregator {
                        Name = "Aggregator1", Field = "contentType", Size = 10
                    }
                }
            };

            // Second Aggregator
            var ranges = new List <NumericRange>
            {
                new NumericRange {
                    From = null, To = 499, Names = new TranslatedStringDictionary {
                        { "en", "Aggregator2a" }
                    }
                },
                new NumericRange {
                    From = 500, To = 5000, Names = new TranslatedStringDictionary {
                        { "en", "Aggregator2b" }
                    }
                }
            };

            var numRangeAggregator = new NumericRangeAggregator()
            {
                Name   = "NumberAggregator",
                Field  = "Original.Width",
                Ranges = ranges
            };

            request.Aggregators.Add(numRangeAggregator);
            ObjectAggregationResult result = await _client.Contents.AggregateAsync(request);
        }