@@ -252,17 +252,35 @@ [U] public void MixAndMatchMinimumShouldMatch() =>
252252
253253 [ U ] public void DoNotCombineLockedBools ( ) =>
254254 Assert (
255- q => q . Bool ( b=> b . Name ( "firstBool" ) . Should ( mq=> mq . Query ( ) ) )
256- || q . Bool ( b=> b . Name ( "secondBool" ) . Should ( mq=> mq . Query ( ) ) ) ,
257- new BoolQuery { Name = "firstBool" , Should = new QueryContainer [ ] { Query } }
258- || new BoolQuery { Name = "secondBool" , Should = new QueryContainer [ ] { Query } } ,
259- c=>
260- {
261- c . Bool . Should . Should ( ) . HaveCount ( 2 ) ;
262- var nestedBool = c . Bool . Should . First ( ) as IQueryContainer ;
263- nestedBool . Bool . Should . Should ( ) . HaveCount ( 1 ) ;
264- nestedBool . Bool . Name . Should ( ) . Be ( "firstBool" ) ;
265- } ) ;
255+ q => q . Bool ( b=> b . Name ( "leftBool" ) . Should ( mq=> mq . Query ( ) ) )
256+ || q . Bool ( b=> b . Name ( "rightBool" ) . Should ( mq=> mq . Query ( ) ) ) ,
257+ new BoolQuery { Name = "leftBool" , Should = new QueryContainer [ ] { Query } }
258+ || new BoolQuery { Name = "rightBool" , Should = new QueryContainer [ ] { Query } } ,
259+ c=> AssertDoesNotJoinOntoLockedBool ( c , "leftBool" ) ) ;
260+
261+ [ U ] public void DoNotCombineRightLockedBool ( ) =>
262+ Assert (
263+ q => q . Bool ( b=> b . Should ( mq=> mq . Query ( ) ) )
264+ || q . Bool ( b=> b . Name ( "rightBool" ) . Should ( mq=> mq . Query ( ) ) ) ,
265+ new BoolQuery { Should = new QueryContainer [ ] { Query } }
266+ || new BoolQuery { Name = "rightBool" , Should = new QueryContainer [ ] { Query } } ,
267+ c=> AssertDoesNotJoinOntoLockedBool ( c , "rightBool" ) ) ;
268+
269+ [ U ] public void DoNotCombineLeftLockedBool ( ) =>
270+ Assert (
271+ q => q . Bool ( b=> b . Name ( "leftBool" ) . Should ( mq=> mq . Query ( ) ) )
272+ || q . Bool ( b=> b . Should ( mq=> mq . Query ( ) ) ) ,
273+ new BoolQuery { Name = "leftBool" , Should = new QueryContainer [ ] { Query } }
274+ || new BoolQuery { Should = new QueryContainer [ ] { Query } } ,
275+ c=> AssertDoesNotJoinOntoLockedBool ( c , "leftBool" ) ) ;
276+
277+ private static void AssertDoesNotJoinOntoLockedBool ( IQueryContainer c , string firstName )
278+ {
279+ c . Bool . Should . Should ( ) . HaveCount ( 2 ) ;
280+ var nestedBool = c . Bool . Should . Cast < IQueryContainer > ( ) . First ( b=> ! string . IsNullOrEmpty ( b . Bool ? . Name ) ) ;
281+ nestedBool . Bool . Should . Should ( ) . HaveCount ( 1 ) ;
282+ nestedBool . Bool . Name . Should ( ) . Be ( firstName ) ;
283+ }
266284
267285
268286 private void Assert (
0 commit comments