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