@@ -96,6 +96,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
96
96
public async Task Returns_no_ETag_for_failed_GET_request ( )
97
97
{
98
98
// Arrange
99
+ string unknownCountryId = Unknown . StringId . For < Country , Guid > ( ) ;
100
+
99
101
using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
100
102
var apiClient = new HeadersClient ( requestAdapter ) ;
101
103
@@ -105,13 +107,19 @@ public async Task Returns_no_ETag_for_failed_GET_request()
105
107
} ;
106
108
107
109
// Act
108
- Func < Task < CountryPrimaryResponseDocument ? > > action = ( ) => apiClient . Countries [ Unknown . StringId . For < Country , Guid > ( ) ]
109
- . GetAsync ( configuration => configuration . Options . Add ( headerInspector ) ) ;
110
+ Func < Task < CountryPrimaryResponseDocument ? > > action = ( ) =>
111
+ apiClient . Countries [ unknownCountryId ] . GetAsync ( configuration => configuration . Options . Add ( headerInspector ) ) ;
110
112
111
113
// Assert
112
114
ErrorResponseDocument exception = ( await action . Should ( ) . ThrowExactlyAsync < ErrorResponseDocument > ( ) ) . Which ;
115
+ exception . ResponseStatusCode . Should ( ) . Be ( ( int ) HttpStatusCode . NotFound ) ;
116
+ exception . Message . Should ( ) . Be ( $ "Exception of type '{ typeof ( ErrorResponseDocument ) . FullName } ' was thrown.") ;
113
117
exception . Errors . ShouldHaveCount ( 1 ) ;
114
- exception . Errors [ 0 ] . Status . Should ( ) . Be ( ( ( int ) HttpStatusCode . NotFound ) . ToString ( ) ) ;
118
+
119
+ ErrorObject error = exception . Errors . ElementAt ( 0 ) ;
120
+ error . Status . Should ( ) . Be ( "404" ) ;
121
+ error . Title . Should ( ) . Be ( "The requested resource does not exist." ) ;
122
+ error . Detail . Should ( ) . Be ( $ "Resource of type 'countries' with ID '{ unknownCountryId } ' does not exist.") ;
115
123
116
124
headerInspector . ResponseHeaders . Should ( ) . NotContainKey ( HeaderNames . ETag ) ;
117
125
}
@@ -188,6 +196,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
188
196
189
197
// Assert
190
198
ApiException exception = ( await action . Should ( ) . ThrowExactlyAsync < ApiException > ( ) ) . Which ;
199
+ exception . Message . Should ( ) . Be ( "The server returned an unexpected status code and no error factory is registered for this code: 304" ) ;
191
200
exception . ResponseStatusCode . Should ( ) . Be ( ( int ) HttpStatusCode . NotModified ) ;
192
201
193
202
string [ ] eTagHeaderValues = headerInspector . ResponseHeaders . Should ( ) . ContainKey ( HeaderNames . ETag ) . WhoseValue . ToArray ( ) ;
0 commit comments