public async Task Aggregate_Count_Tests()
        {
            var target = this.testHost.GetService <IDocumentRepository>();
            await target.DeleteAllDocumentsFromAuthorAsync("test");

            await target.AddAsync(CreateValidDoc(content : "#a #b $v=5", date : "2020-07-05"));

            await target.AddAsync(CreateValidDoc(content : "#a #c", date : "2020-07-05"));

            await target.AddAsync(CreateValidDoc(content : "#a #b", date : "2019-01-01"));

            (await target.AggregateCountAsync("test", GroupTimeRange.Day, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "2020-07-05", Value = 2 },
                new { Key = "2019-01-01", Value = 1 }
            });

            (await target.AggregateCountAsync("test", GroupTimeRange.Week, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "27/2020", Value = 2 },
                new { Key = "01/2019", Value = 1 }
            });

            (await target.AggregateCountAsync("test", GroupTimeRange.Month, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "2020-07", Value = 2 },
                new { Key = "2019-01", Value = 1 }
            });

            (await target.AggregateCountAsync("test", GroupTimeRange.Year, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "2020", Value = 2 },
                new { Key = "2019", Value = 1 }
            });
            (await target.AggregateCountAsync("test", GroupTimeRange.Year, new FilterSettings("a", "b")))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "2020", Value = 1 },
                new { Key = "2019", Value = 1 }
            });
            (await target.AggregateCountAsync("test", GroupTimeRange.Day, FilterSettings.FilterValues("v")))
            .Should().BeEquivalentTo(new[]
            {
                new { Key = "2020-07-05", Value = 1 },
            });
        }
        public async Task Aggregate_Avg_Tests()
        {
            var target = this.testHost.GetService <IDocumentRepository>();
            await target.DeleteAllDocumentsFromAuthorAsync("test");

            await target.AddAsync(CreateValidDoc(content : "#a #b $a=5", date : "2020-07-05"));

            await target.AddAsync(CreateValidDoc(content : "#b $a=3", date : "2020-07-06"));

            await target.AddAsync(CreateValidDoc(content : "#c $b=10", date : "2020-07-05"));

            (await target.AggregateValuesAsync("test", GroupTimeRange.Day, Aggregate.Average, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new ValuesResult {
                    Key = "a", Values = new Dictionary <string, double>
                    {
                        { "2020-07-05", 5 },
                        { "2020-07-06", 3 },
                    }
                },
                new ValuesResult {
                    Key = "b", Values = new Dictionary <string, double>
                    {
                        { "2020-07-05", 10 },
                    }
                },
            });

            (await target.AggregateValuesAsync("test", GroupTimeRange.Month, Aggregate.Average, FilterSettings.Empty))
            .Should().BeEquivalentTo(new[]
            {
                new ValuesResult {
                    Key = "a", Values = new Dictionary <string, double>
                    {
                        { "2020-07", 4 },
                    }
                },
                new ValuesResult {
                    Key = "b", Values = new Dictionary <string, double>
                    {
                        { "2020-07", 10 },
                    }
                },
            });

            (await target.AggregateValuesAsync("test", GroupTimeRange.Month, Aggregate.Average, FilterSettings.FilterValues("a")))
            .Should().BeEquivalentTo(new[]
            {
                new ValuesResult {
                    Key = "a", Values = new Dictionary <string, double>
                    {
                        { "2020-07", 4 },
                    }
                },
            });
        }