|
10 | 10 | using Tests.Framework.MockData;
|
11 | 11 | using Xunit;
|
12 | 12 |
|
13 |
| -namespace Tests.QueryDsl |
| 13 | +namespace Tests.QueryDsl.Verbatim |
14 | 14 | {
|
15 |
| - /** Setting `IsStrict` on the outer query container is a noop */ |
| 15 | + /** `IsVerbatim` should be set on individual queries to take effect */ |
| 16 | + public class CompoundVerbatimQueryUsageTests : QueryDslUsageTestsBase |
| 17 | + { |
| 18 | + protected override bool SupportsDeserialization => false; |
| 19 | + |
| 20 | + public CompoundVerbatimQueryUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
| 21 | + |
| 22 | + protected override object QueryJson => new |
| 23 | + { |
| 24 | + @bool = new |
| 25 | + { |
| 26 | + must = new object[] |
| 27 | + { |
| 28 | + new |
| 29 | + { |
| 30 | + term = new |
| 31 | + { |
| 32 | + description = new |
| 33 | + { |
| 34 | + value = "" |
| 35 | + } |
| 36 | + } |
| 37 | + }, |
| 38 | + new |
| 39 | + { |
| 40 | + term = new |
| 41 | + { |
| 42 | + name = new |
| 43 | + { |
| 44 | + value = "foo" |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + }; |
| 51 | + |
| 52 | + protected override QueryContainer QueryInitializer => |
| 53 | + new TermQuery |
| 54 | + { |
| 55 | + IsVerbatim = true, |
| 56 | + Field = "description", |
| 57 | + Value = "" |
| 58 | + } |
| 59 | + && new TermQuery |
| 60 | + { |
| 61 | + Field = "name", |
| 62 | + Value = "foo" |
| 63 | + }; |
| 64 | + |
| 65 | + protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project> q) => q |
| 66 | + .Bool(b => b |
| 67 | + .Must(qt => qt |
| 68 | + .Term(t => t |
| 69 | + .Verbatim() |
| 70 | + .Field(p => p.Description) |
| 71 | + .Value("") |
| 72 | + ), qt => qt |
| 73 | + .Term(t => t |
| 74 | + .Field(p => p.Name) |
| 75 | + .Value("foo") |
| 76 | + ) |
| 77 | + ) |
| 78 | + ); |
| 79 | + } |
| 80 | + |
| 81 | + /** Setting `IsStrict` on the outer query container does not cascade */ |
16 | 82 | public class QueryContainerStrictQueryUsageTests : QueryDslUsageTestsBase
|
17 | 83 | {
|
18 | 84 | protected override bool SupportsDeserialization => false;
|
@@ -83,7 +149,7 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
|
83 | 149 | #pragma warning restore 618
|
84 | 150 | }
|
85 | 151 |
|
86 |
| - /** Setting `IsVerbatim` on the outer query container is a noop */ |
| 152 | + /** Setting `IsVerbatim` on the outer query container does not cascase */ |
87 | 153 | public class QueryContainerVerbatimQueryUsageTests : QueryDslUsageTestsBase
|
88 | 154 | {
|
89 | 155 | protected override bool SupportsDeserialization => false;
|
@@ -154,69 +220,28 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
|
154 | 220 | #pragma warning restore 618
|
155 | 221 | }
|
156 | 222 |
|
157 |
| - /** `IsVerbatim` should be set on individual queries to take effect */ |
158 |
| - public class CompoundVerbatimQueryUsageTests : QueryDslUsageTestsBase |
| 223 | + /** Setting `IsVerbatim` on a compound query is still supported though */ |
| 224 | + public class QueryContainerVerbatimSupportedUsageTests : QueryDslUsageTestsBase |
159 | 225 | {
|
160 | 226 | protected override bool SupportsDeserialization => false;
|
161 | 227 |
|
162 |
| - public CompoundVerbatimQueryUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
| 228 | + public QueryContainerVerbatimSupportedUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
163 | 229 |
|
164 | 230 | protected override object QueryJson => new
|
165 | 231 | {
|
166 | 232 | @bool = new
|
167 | 233 | {
|
168 |
| - must = new object[] |
169 |
| - { |
170 |
| - new |
171 |
| - { |
172 |
| - term = new |
173 |
| - { |
174 |
| - description = new |
175 |
| - { |
176 |
| - value = "" |
177 |
| - } |
178 |
| - } |
179 |
| - }, |
180 |
| - new |
181 |
| - { |
182 |
| - term = new |
183 |
| - { |
184 |
| - name = new |
185 |
| - { |
186 |
| - value = "foo" |
187 |
| - } |
188 |
| - } |
189 |
| - } |
190 |
| - } |
191 | 234 | }
|
192 | 235 | };
|
193 | 236 |
|
194 |
| - protected override QueryContainer QueryInitializer => |
195 |
| - new TermQuery |
196 |
| - { |
197 |
| - IsVerbatim = true, |
198 |
| - Field = "description", |
199 |
| - Value = "" |
200 |
| - } |
201 |
| - && new TermQuery |
202 |
| - { |
203 |
| - Field = "name", |
204 |
| - Value = "foo" |
205 |
| - }; |
| 237 | + protected override QueryContainer QueryInitializer => new BoolQuery |
| 238 | + { |
| 239 | + IsVerbatim = true, |
| 240 | + }; |
206 | 241 |
|
207 | 242 | protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project> q) => q
|
208 | 243 | .Bool(b => b
|
209 |
| - .Must(qt => qt |
210 |
| - .Term(t => t |
211 |
| - .Verbatim() |
212 |
| - .Field(p => p.Description) |
213 |
| - .Value("") |
214 |
| - ), qt => qt |
215 |
| - .Term(t => t |
216 |
| - .Field(p => p.Name) |
217 |
| - .Value("foo") |
218 |
| - ) |
219 |
| - ) |
| 244 | + .Verbatim() |
220 | 245 | );
|
221 | 246 | }
|
222 | 247 |
|
|
0 commit comments