@@ -643,46 +643,31 @@ await index.GetDocumentsAsync<Movie>(new DocumentsQuery()
643643 documents . Results . Last ( ) . Id . Should ( ) . Be ( "11" ) ;
644644 }
645645
646- [ Fact ]
647- public async Task GetMultipleExistingDocumentWithAscSort ( )
648- {
649- var index = await _fixture . SetUpBasicIndexWithIntId ( "GetOneExistingDocumentWithIntegerIdTest" ) ;
650- var updateSortable = await index . UpdateSortableAttributesAsync ( new [ ] { "id" } ) ;
651- updateSortable . TaskUid . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
652- await index . WaitForTaskAsync ( updateSortable . TaskUid ) ;
653-
654- var documents =
655- await index . GetDocumentsAsync < MovieWithIntId > ( new DocumentsQuery ( )
656- {
657- Sort = new List < string > { "id:asc" }
658- } ) ;
659-
660- Assert . Equal ( 7 , documents . Results . Count ( ) ) ;
661- documents . Results . Should ( ) . BeInAscendingOrder ( x => x . Id ) ;
662- }
663-
664- [ Fact ]
665- public async Task GetMultipleExistingDocumentWithDescSort ( )
646+ [ Theory ]
647+ [ InlineData ( "id:asc" , true ) ]
648+ [ InlineData ( "id:desc" , false ) ]
649+ public async Task GetMultipleExistingDocumentsWithIdSort ( string sort , bool ascending )
666650 {
667- var index = await _fixture . SetUpBasicIndexWithIntId ( "GetOneExistingDocumentWithIntegerIdTest ") ;
651+ var index = await _fixture . SetUpBasicIndexWithIntId ( $ "GetMultipleExistingDocumentsWithIdSort_ { ( ascending ? "Asc" : "Desc" ) } Test ") ;
668652 var updateSortable = await index . UpdateSortableAttributesAsync ( new [ ] { "id" } ) ;
669653 updateSortable . TaskUid . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
670654 await index . WaitForTaskAsync ( updateSortable . TaskUid ) ;
671655
672- var documents =
673- await index . GetDocumentsAsync < MovieWithIntId > ( new DocumentsQuery ( )
674- {
675- Sort = new List < string > { "id:desc" }
676- } ) ;
656+ var results = ( await index . GetDocumentsAsync < MovieWithIntId > (
657+ new DocumentsQuery { Sort = new List < string > { sort } }
658+ ) ) . Results . ToList ( ) ;
677659
678- Assert . Equal ( 7 , documents . Results . Count ( ) ) ;
679- documents . Results . Should ( ) . BeInDescendingOrder ( x => x . Id ) ;
660+ Assert . Equal ( 7 , results . Count ) ;
661+ if ( ascending )
662+ results . Should ( ) . BeInAscendingOrder ( x => x . Id ) ;
663+ else
664+ results . Should ( ) . BeInDescendingOrder ( x => x . Id ) ;
680665 }
681666
682667 [ Fact ]
683- public async Task GetMultipleExistingDocumentWithMultiSort ( )
668+ public async Task GetMultipleExistingDocumentsWithMultiSort ( )
684669 {
685- var index = await _fixture . SetUpBasicIndexWithIntId ( "GetOneExistingDocumentWithIntegerIdTest " ) ;
670+ var index = await _fixture . SetUpBasicIndexWithIntId ( "GetMultipleExistingDocumentsWithMultiSort " ) ;
686671 var updateFilterable = await index . UpdateFilterableAttributesAsync ( new [ ] { "genre" } ) ;
687672 updateFilterable . TaskUid . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
688673 await index . WaitForTaskAsync ( updateFilterable . TaskUid ) ;
@@ -691,20 +676,29 @@ public async Task GetMultipleExistingDocumentWithMultiSort()
691676 updateSortable . TaskUid . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
692677 await index . WaitForTaskAsync ( updateSortable . TaskUid ) ;
693678
694- var documents =
695- await index . GetDocumentsAsync < MovieWithIntId > ( new DocumentsQuery ( )
679+ var results = ( await index . GetDocumentsAsync < MovieWithIntId > (
680+ new DocumentsQuery
696681 {
697682 Filter = "genre IN ['SF','Action']" ,
698683 Sort = new List < string > { "genre:asc" , "name:desc" }
699- } ) ;
684+ }
685+ ) ) . Results . ToList ( ) ;
700686
701- Assert . Equal ( 4 , documents . Results . Count ( ) ) ;
702- var first = documents . Results . First ( ) ;
687+ Assert . Equal ( 4 , results . Count ) ;
688+ var first = results . First ( ) ;
703689 first . Genre . Should ( ) . Be ( "Action" ) ;
704690 first . Name . Should ( ) . Be ( "Spider-Man" ) ;
705- var last = documents . Results . Last ( ) ;
691+ var last = results . Last ( ) ;
706692 last . Genre . Should ( ) . Be ( "SF" ) ;
707693 last . Name . Should ( ) . Be ( "Harry Potter" ) ;
694+
695+ results . Should ( ) . BeInAscendingOrder ( x => x . Genre ) ;
696+ var split = results . FindIndex ( x => x . Genre == "SF" ) ;
697+ split . Should ( ) . BeGreaterThan ( 0 ) ; // at least one Action before SF
698+ results . Take ( split ) . Should ( ) . OnlyContain ( x => x . Genre == "Action" ) ;
699+ results . Skip ( split ) . Should ( ) . OnlyContain ( x => x . Genre == "SF" ) ;
700+ results . Take ( split ) . Should ( ) . BeInDescendingOrder ( x => x . Name ) ;
701+ results . Skip ( split ) . Should ( ) . BeInDescendingOrder ( x => x . Name ) ;
708702 }
709703
710704 [ Fact ]
0 commit comments