public void Densify_values_within_each_partition_example_using_linq_should_work()
        {
            RequireServer.Check().Supports(Feature.DensifyStage);
            var collection = CreateCoffeeCollection();
            var subject    = collection.AsQueryable();

            var queryable = subject.Densify(
                field: x => x.Altitude,
                range: DensifyRange.Numeric(DensifyBounds.Partition, step: 200),
                partitionByFields: x => x.Variety);

            var stages = Translate(collection, queryable);

            AssertStages(stages, "{ $densify : { field : 'Altitude', partitionByFields : ['Variety'], range : { step : 200, bounds : 'partition' } } }");

            var results         = queryable.ToList().Select(r => new { Variety = r.Variety, Altitude = r.Altitude }).OrderBy(r => r.Variety).ThenBy(r => r.Altitude).ToList();
            var expectedResults = new[]
            {
                new { Variety = "Arabica Typica", Altitude = 600 },
                new { Variety = "Arabica Typica", Altitude = 750 },
                new { Variety = "Arabica Typica", Altitude = 800 },
                new { Variety = "Arabica Typica", Altitude = 950 },
                new { Variety = "Gesha", Altitude = 1250 },
                new { Variety = "Gesha", Altitude = 1450 },
                new { Variety = "Gesha", Altitude = 1650 },
                new { Variety = "Gesha", Altitude = 1700 }
            };

            results.Should().Equal(expectedResults);
        }
        public void Densify_the_full_range_of_values_example_using_aggregate_should_work(bool usingExpressions)
        {
            RequireServer.Check().Supports(Feature.DensifyStage);
            var collection = CreateCoffeeCollection();
            var subject    = collection.Aggregate();

            IAggregateFluent <CoffeeInfo> aggregate;

            if (usingExpressions)
            {
                aggregate = subject.Densify(
                    field: x => x.Altitude,
                    range: DensifyRange.Numeric(DensifyBounds.Full, step: 200),
                    partitionByFields: x => x.Variety);
            }
            else
            {
                aggregate = subject.Densify(
                    field: "Altitude",
                    range: DensifyRange.Numeric(DensifyBounds.Full, step: 200),
                    partitionByFields: "Variety");
            }

            var stages = Translate(collection, aggregate);

            AssertStages(stages, "{ $densify : { field : 'Altitude', partitionByFields : ['Variety'], range : { step : 200, bounds : 'full' } } }");

            var results         = aggregate.ToList().Select(r => new { Variety = r.Variety, Altitude = r.Altitude }).OrderBy(r => r.Variety).ThenBy(r => r.Altitude).ToList();
            var expectedResults = new[]
            {
                new { Variety = "Arabica Typica", Altitude = 600 },
                new { Variety = "Arabica Typica", Altitude = 750 },
                new { Variety = "Arabica Typica", Altitude = 800 },
                new { Variety = "Arabica Typica", Altitude = 950 },
                new { Variety = "Arabica Typica", Altitude = 1000 },
                new { Variety = "Arabica Typica", Altitude = 1200 },
                new { Variety = "Arabica Typica", Altitude = 1400 },
                new { Variety = "Arabica Typica", Altitude = 1600 },
                new { Variety = "Gesha", Altitude = 600 },
                new { Variety = "Gesha", Altitude = 800 },
                new { Variety = "Gesha", Altitude = 1000 },
                new { Variety = "Gesha", Altitude = 1200 },
                new { Variety = "Gesha", Altitude = 1250 },
                new { Variety = "Gesha", Altitude = 1400 },
                new { Variety = "Gesha", Altitude = 1600 },
                new { Variety = "Gesha", Altitude = 1700 }
            };

            results.Should().Equal(expectedResults);
        }