-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathGitHubIssue6050.cs
75 lines (68 loc) · 1.95 KB
/
GitHubIssue6050.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System;
using System.Text;
using Elastic.Elasticsearch.Xunit.XunitPlumbing;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
namespace Tests.Reproduce
{
public class GitHubIssue6050
{
private static readonly byte[] ResponseBytes = Encoding.UTF8.GetBytes(@"{
""took"" : 1,
""timed_out"" : false,
""_shards"" : {
""total"" : 1,
""successful"" : 1,
""skipped"" : 0,
""failed"" : 0
},
""hits"" : {
""total"" : {
""value"" : 0,
""relation"" : ""eq""
},
""max_score"" : null,
""hits"" : [ ]
},
""aggregations"" : {
""summary_boxplot"" : {
""min"" : ""Infinity"",
""max"" : ""-Infinity"",
""q1"" : ""NaN"",
""q2"" : ""NaN"",
""q3"" : ""NaN"",
""lower"" : ""NaN"",
""upper"" : ""-Infinity""
}
}
}");
[U]
public void BoxplotHandlesNaNValues()
{
var pool = new SingleNodeConnectionPool(new Uri($"http://localhost:9200"));
var settings = new ConnectionSettings(pool, new InMemoryConnection(ResponseBytes));
var client = new ElasticClient(settings);
var response = client.Search<TestData>(s => s
.Size(0)
.Index("test")
.Aggregations(a => a
.Boxplot("summary_boxplot", mt => mt.Field(f => f.Population))));
var boxplot = response.Aggregations.Boxplot("summary_boxplot");
double.IsNaN(boxplot.Lower).Should().BeTrue();
double.IsNaN(boxplot.Q1).Should().BeTrue();
double.IsNaN(boxplot.Q2).Should().BeTrue();
double.IsNaN(boxplot.Q3).Should().BeTrue();
double.IsInfinity(boxplot.Min).Should().BeTrue();
double.IsNegativeInfinity(boxplot.Max).Should().BeTrue();
double.IsNegativeInfinity(boxplot.Upper).Should().BeTrue();
}
private class TestData
{
public long Population { get; set; }
}
}
}