@@ -111,7 +111,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
111
111
var startDates = response . Aggregations . Terms ( "startDates" ) ;
112
112
startDates . Should ( ) . NotBeNull ( ) ;
113
113
114
- foreach ( var document in response . Documents ) document . ShouldAdhereToSourceSerializerWhenSet ( ) ;
114
+ foreach ( var document in response . Documents )
115
+ document . ShouldAdhereToSourceSerializerWhenSet ( ) ;
115
116
}
116
117
}
117
118
@@ -539,20 +540,20 @@ protected override void ExpectResponse(ListTasksResponse response)
539
540
{
540
541
response . ShouldBeValid ( ) ;
541
542
foreach ( var node in response . Nodes )
542
- foreach ( var task in node . Value . Tasks )
543
- {
544
- task . Value . Headers . Should ( ) . NotBeNull ( ) ;
545
- if ( task . Value . Headers . TryGetValue ( RequestData . OpaqueIdHeader , out var opaqueIdValue ) )
546
- opaqueIdValue . Should ( )
547
- . Be ( CallIsolatedValue ,
548
- $ "OpaqueId header { opaqueIdValue } did not match { CallIsolatedValue } ") ;
549
- // TODO: Determine if this is a valid assertion i.e. should all tasks returned have an OpaqueId header?
550
- // else
551
- // {
552
- // Assert.True(false,
553
- // $"No OpaqueId header for task {task.Key} and OpaqueId value {this.CallIsolatedValue}");
554
- // }
555
- }
543
+ foreach ( var task in node . Value . Tasks )
544
+ {
545
+ task . Value . Headers . Should ( ) . NotBeNull ( ) ;
546
+ if ( task . Value . Headers . TryGetValue ( RequestData . OpaqueIdHeader , out var opaqueIdValue ) )
547
+ opaqueIdValue . Should ( )
548
+ . Be ( CallIsolatedValue ,
549
+ $ "OpaqueId header { opaqueIdValue } did not match { CallIsolatedValue } ") ;
550
+ // TODO: Determine if this is a valid assertion i.e. should all tasks returned have an OpaqueId header?
551
+ // else
552
+ // {
553
+ // Assert.True(false,
554
+ // $"No OpaqueId header for task {task.Key} and OpaqueId value {this.CallIsolatedValue}");
555
+ // }
556
+ }
556
557
}
557
558
}
558
559
@@ -609,7 +610,7 @@ public class SearchWithPointInTimeApiTests
609
610
: ApiTestBase < ReadOnlyCluster , ISearchResponse < Project > , ISearchRequest , SearchDescriptor < Project > , SearchRequest < Project > >
610
611
{
611
612
public SearchWithPointInTimeApiTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
612
-
613
+
613
614
protected override object ExpectJson => new
614
615
{
615
616
size = 1 ,
@@ -623,7 +624,7 @@ public SearchWithPointInTimeApiTests(ReadOnlyCluster cluster, EndpointUsage usag
623
624
keep_alive = "1m"
624
625
}
625
626
} ;
626
-
627
+
627
628
protected override Func < SearchDescriptor < Project > , ISearchRequest > Fluent => s => s
628
629
. Size ( 1 )
629
630
. Query ( q => q . MatchAll ( ) )
@@ -674,7 +675,7 @@ public SearchApiRuntimeFieldsTests(ReadOnlyCluster cluster, EndpointUsage usage)
674
675
} ,
675
676
"search_runtime_field"
676
677
} ,
677
- runtime_mappings = new
678
+ runtime_mappings = new
678
679
{
679
680
search_runtime_field = new
680
681
{
@@ -739,4 +740,60 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
739
740
}
740
741
}
741
742
}
743
+
744
+ [ SkipVersion ( "<7.13.0" , "Format for sort values added in Elasticsearch 7.13.0" ) ]
745
+ public class SearchApiSortFormatTests : SearchApiTests
746
+ {
747
+ public SearchApiSortFormatTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
748
+
749
+ protected override object ExpectJson => new
750
+ {
751
+ size = 5 ,
752
+ query = new
753
+ {
754
+ match_all = new { }
755
+ } ,
756
+ sort = new [ ]
757
+ {
758
+ new
759
+ {
760
+ startedOn = new
761
+ {
762
+ format = "strict_date_optional_time_nanos" ,
763
+ mode = "avg" ,
764
+ order = "asc"
765
+ }
766
+ }
767
+ }
768
+ } ;
769
+
770
+ protected override Func < SearchDescriptor < Project > , ISearchRequest > Fluent => s => s
771
+ . Size ( 5 )
772
+ . Query ( q => q
773
+ . MatchAll ( )
774
+ )
775
+ . Sort ( srt => srt . Field ( f => f
776
+ . Field ( fld => fld . StartedOn )
777
+ . Order ( SortOrder . Ascending )
778
+ . Format ( "strict_date_optional_time_nanos" )
779
+ . Mode ( SortMode . Average ) ) ) ;
780
+
781
+ protected override SearchRequest < Project > Initializer => new ( )
782
+ {
783
+ Size = 5 ,
784
+ Query = new QueryContainer ( new MatchAllQuery ( ) ) ,
785
+ Sort = new List < ISort >
786
+ {
787
+ new FieldSort
788
+ {
789
+ Field = Infer . Field < Project > ( f => f . StartedOn ) ,
790
+ Format = "strict_date_optional_time_nanos" ,
791
+ Mode = SortMode . Average ,
792
+ Order = SortOrder . Ascending
793
+ }
794
+ }
795
+ } ;
796
+
797
+ protected override void ExpectResponse ( ISearchResponse < Project > response ) => response . Hits . Count . Should ( ) . BeGreaterThan ( 0 ) ;
798
+ }
742
799
}
0 commit comments