Handling Responses

edit

Using the .Agg aggregation helper we can fetch our aggregation results easily in the correct type. Be sure to read more about .Aggs vs .Aggregations

Handling Responses

edit
response.ShouldBeValid();

var dateHistogram = response.Aggs.DateRange("projects_date_ranges");
dateHistogram.Should().NotBeNull();
dateHistogram.Buckets.Should().NotBeNull();

We specified three ranges so we expect to have three of them in the response

dateHistogram.Buckets.Count.Should().Be(3);
foreach (var item in dateHistogram.Buckets)
{
    item.DocCount.Should().BeGreaterThan(0);
}