Skip to content

Commit 4cf01cd

Browse files
committed
Attempt to reproduce #1304
1 parent 62d6a9d commit 4cf01cd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
<Compile Include="Reproduce\Reproduce1193Tests.cs" />
174174
<Compile Include="Reproduce\Reproduce1236Tests.cs" />
175175
<Compile Include="Reproduce\Reproduce1278Tests.cs" />
176+
<Compile Include="Reproduce\Reproduce1304Tests.cs" />
176177
<Compile Include="Reproduce\Reproduce769Tests.cs" />
177178
<Compile Include="Reproduce\Reproduce945Tests.cs" />
178179
<Compile Include="Reproduce\Reproduce953Tests.cs" />
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using FluentAssertions;
7+
using NUnit.Framework;
8+
using Nest.Tests.MockData.Domain;
9+
using Newtonsoft.Json.Linq;
10+
using System.IO;
11+
12+
namespace Nest.Tests.Integration.Reproduce
13+
{
14+
[TestFixture]
15+
public class Reproduce1304Tests : IntegrationTests
16+
{
17+
[Test]
18+
public void AndFilterSerializationTest()
19+
{
20+
var descriptor1 = new SearchDescriptor<ElasticsearchProject>()
21+
.From(0)
22+
.Size(5)
23+
.Query(q => q
24+
.Filtered(f => f
25+
.Query(qq => qq
26+
.QueryString(qs => qs
27+
.Query("*")
28+
)
29+
)
30+
.Filter(ff => ff
31+
.And(a => a
32+
.Range(r => r
33+
.OnField(p => p.StartedOn)
34+
.GreaterOrEquals("2000-10-10T00:00:00")
35+
.LowerOrEquals("2000-10-10T00:00:00")
36+
),
37+
a => a.Exists(p => p.Name),
38+
a => a.Exists(p => p.Country),
39+
a => a.Exists(p => p.Content)
40+
)
41+
)
42+
)
43+
);
44+
var json1Bytes = this.Client.Serializer.Serialize(descriptor1);
45+
var json1String = Encoding.UTF8.GetString(json1Bytes);
46+
47+
var descriptor2 = this.Client.Serializer.Deserialize<SearchDescriptor<ElasticsearchProject>>(new MemoryStream(json1Bytes));
48+
var json2Bytes = this.Client.Serializer.Serialize(descriptor2);
49+
var json2String = Encoding.UTF8.GetString(json2Bytes);
50+
51+
JToken.DeepEquals(JObject.Parse(json1String), JObject.Parse(json2String)).Should().BeTrue();
52+
53+
var result = this.Client.Search<ElasticsearchProject>(descriptor1);
54+
result.IsValid.Should().BeTrue();
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)