@@ -33,9 +33,9 @@ public EndpointTests(BhsWebApplicationFactory<Program> factory)
33
33
[ Fact ]
34
34
public async Task HealthCheck_Ok ( )
35
35
{
36
- using var response = await _httpClient . GetAsync ( "/api/healthcheck/status" ) ;
36
+ using var response = await _httpClient . GetAsync ( "/api/healthcheck/status" , TestContext . Current . CancellationToken ) ;
37
37
38
- string content = await response . Content . ReadAsStringAsync ( ) ;
38
+ string content = await response . Content . ReadAsStringAsync ( TestContext . Current . CancellationToken ) ;
39
39
40
40
Assert . Equal ( "Healthy" , content ) ;
41
41
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
@@ -44,7 +44,7 @@ public async Task HealthCheck_Ok()
44
44
[ Fact ]
45
45
public async Task Swagger_Ok ( )
46
46
{
47
- using var response = await _httpClient . GetAsync ( "/api/swagger/index.html" ) ;
47
+ using var response = await _httpClient . GetAsync ( "/api/swagger/index.html" , TestContext . Current . CancellationToken ) ;
48
48
49
49
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
50
50
Assert . Equal ( MediaTypeNames . Text . Html , response . Content . Headers . ContentType ? . MediaType ) ;
@@ -57,15 +57,15 @@ public async Task Author_GetByAuthUserId_InvalidFormat_400()
57
57
. GetAsync < User > ( Arg . Any < Uri > ( ) , Arg . Any < Dictionary < string , string > > ( ) , null , Arg . Any < CancellationToken > ( ) )
58
58
. Throws ( new ErrorApiException ( HttpStatusCode . BadRequest ) ) ;
59
59
60
- using var response = await _httpClient . GetAsync ( "/api/authors?authUserId=12345" ) ;
60
+ using var response = await _httpClient . GetAsync ( "/api/authors?authUserId=12345" , TestContext . Current . CancellationToken ) ;
61
61
62
62
Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
63
63
}
64
64
65
65
[ Fact ]
66
66
public async Task Author_GetPosts_Empty ( )
67
67
{
68
- var posts = await _httpClient . GetFromJsonAsync < IEnumerable < PostPreview > > ( $ "/api/authors/{ Random . Shared . Next ( ) } /posts") ;
68
+ var posts = await _httpClient . GetFromJsonAsync < IEnumerable < PostPreview > > ( $ "/api/authors/{ Random . Shared . Next ( ) } /posts", TestContext . Current . CancellationToken ) ;
69
69
70
70
Assert . NotNull ( posts ) ;
71
71
Assert . Empty ( posts ) ;
@@ -74,7 +74,7 @@ public async Task Author_GetPosts_Empty()
74
74
[ Fact ]
75
75
public async Task Banners_GetCurrent ( )
76
76
{
77
- var banners = await _httpClient . GetFromJsonAsync < IEnumerable < SiteBanner > > ( "/api/banners/current" ) ;
77
+ var banners = await _httpClient . GetFromJsonAsync < IEnumerable < SiteBanner > > ( "/api/banners/current" , TestContext . Current . CancellationToken ) ;
78
78
79
79
Assert . NotNull ( banners ) ;
80
80
Assert . Empty ( banners ) ;
@@ -83,7 +83,7 @@ public async Task Banners_GetCurrent()
83
83
[ Fact ]
84
84
public async Task Blog_GetPosts ( )
85
85
{
86
- var posts = await _httpClient . GetFromJsonAsync < IEnumerable < PostPreview > > ( "/api/blog/posts" ) ;
86
+ var posts = await _httpClient . GetFromJsonAsync < IEnumerable < PostPreview > > ( "/api/blog/posts" , TestContext . Current . CancellationToken ) ;
87
87
88
88
Assert . NotNull ( posts ) ;
89
89
Assert . Empty ( posts ) ;
@@ -102,10 +102,10 @@ public async Task Blog_CreatePost()
102
102
datePublished ,
103
103
[ new Category ( "newsletters" , "Newsletters" ) ] ) ;
104
104
105
- using var response = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , request ) ;
105
+ using var response = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , request , TestContext . Current . CancellationToken ) ;
106
106
107
107
Assert . Equal ( HttpStatusCode . Created , response . StatusCode ) ;
108
- var post = await response . Content . ReadFromJsonAsync < Post > ( ) ;
108
+ var post = await response . Content . ReadFromJsonAsync < Post > ( TestContext . Current . CancellationToken ) ;
109
109
110
110
Assert . NotNull ( post ) ;
111
111
Assert . Contains ( "-hello-world" , post . Slug ) ;
@@ -139,16 +139,16 @@ public async Task Blog_UpdatePost()
139
139
Categories = [ new Category ( "cat1" , "Cat1" ) , new Category ( "cat3" , "Cat3" ) ] ,
140
140
} ;
141
141
142
- using var createResponse = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , createRequest ) ;
142
+ using var createResponse = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , createRequest , TestContext . Current . CancellationToken ) ;
143
143
144
144
Assert . Equal ( HttpStatusCode . Created , createResponse . StatusCode ) ;
145
- var initialPost = await createResponse . Content . ReadFromJsonAsync < Post > ( ) ;
145
+ var initialPost = await createResponse . Content . ReadFromJsonAsync < Post > ( TestContext . Current . CancellationToken ) ;
146
146
Assert . NotNull ( initialPost ? . Slug ) ;
147
147
148
- using var response2 = await _httpClient . PutAsJsonAsync ( $ "/api/blog/posts/{ initialPost . Slug } ", updateRequest ) ;
148
+ using var response2 = await _httpClient . PutAsJsonAsync ( $ "/api/blog/posts/{ initialPost . Slug } ", updateRequest , TestContext . Current . CancellationToken ) ;
149
149
150
150
Assert . Equal ( HttpStatusCode . OK , response2 . StatusCode ) ;
151
- var updatedPost = await response2 . Content . ReadFromJsonAsync < Post > ( ) ;
151
+ var updatedPost = await response2 . Content . ReadFromJsonAsync < Post > ( TestContext . Current . CancellationToken ) ;
152
152
153
153
Assert . NotNull ( updatedPost ) ;
154
154
Assert . Equal ( initialPost . Slug , updatedPost . Slug ) ;
@@ -170,45 +170,45 @@ public async Task Blog_DeletePost()
170
170
DateTimeOffset . Now ,
171
171
[ ] ) ;
172
172
173
- using var createResponse = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , createRequest ) ;
173
+ using var createResponse = await _httpClient . PostAsJsonAsync ( "/api/blog/posts" , createRequest , TestContext . Current . CancellationToken ) ;
174
174
175
175
Assert . Equal ( HttpStatusCode . Created , createResponse . StatusCode ) ;
176
- var post = await createResponse . Content . ReadFromJsonAsync < Post > ( ) ;
176
+ var post = await createResponse . Content . ReadFromJsonAsync < Post > ( TestContext . Current . CancellationToken ) ;
177
177
Assert . NotNull ( post ) ;
178
178
179
- using var deleteResponse = await _httpClient . DeleteAsync ( $ "/api/blog/posts/{ post . Slug } ") ;
179
+ using var deleteResponse = await _httpClient . DeleteAsync ( $ "/api/blog/posts/{ post . Slug } ", TestContext . Current . CancellationToken ) ;
180
180
181
181
Assert . Equal ( HttpStatusCode . NoContent , deleteResponse . StatusCode ) ;
182
182
}
183
183
184
184
[ Fact ]
185
185
public async Task Blog_GetPostById_404 ( )
186
186
{
187
- using var response = await _httpClient . GetAsync ( $ "/api/blog/posts/{ Random . Shared . Next ( ) } ") ;
187
+ using var response = await _httpClient . GetAsync ( $ "/api/blog/posts/{ Random . Shared . Next ( ) } ", TestContext . Current . CancellationToken ) ;
188
188
189
189
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
190
190
}
191
191
192
192
[ Fact ]
193
193
public async Task Blog_GetCategories ( )
194
194
{
195
- var categories = await _httpClient . GetFromJsonAsync < IEnumerable < CategorySummary > > ( "/api/blog/categories" ) ;
195
+ var categories = await _httpClient . GetFromJsonAsync < IEnumerable < CategorySummary > > ( "/api/blog/categories" , TestContext . Current . CancellationToken ) ;
196
196
197
197
Assert . NotNull ( categories ) ;
198
198
}
199
199
200
200
[ Fact ]
201
201
public async Task Blog_GetCategoryById_404 ( )
202
202
{
203
- using var response = await _httpClient . GetAsync ( $ "/api/blog/categories/{ Random . Shared . Next ( ) } ") ;
203
+ using var response = await _httpClient . GetAsync ( $ "/api/blog/categories/{ Random . Shared . Next ( ) } ", TestContext . Current . CancellationToken ) ;
204
204
205
205
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
206
206
}
207
207
208
208
[ Fact ]
209
209
public async Task Leadership_GetOfficers ( )
210
210
{
211
- var officers = await _httpClient . GetFromJsonAsync < IEnumerable < Officer > > ( "/api/leadership/officers" ) ;
211
+ var officers = await _httpClient . GetFromJsonAsync < IEnumerable < Officer > > ( "/api/leadership/officers" , TestContext . Current . CancellationToken ) ;
212
212
213
213
Assert . NotNull ( officers ) ;
214
214
Assert . Empty ( officers ) ;
@@ -217,7 +217,7 @@ public async Task Leadership_GetOfficers()
217
217
[ Fact ]
218
218
public async Task Leadership_GetDirectors ( )
219
219
{
220
- var directors = await _httpClient . GetFromJsonAsync < IEnumerable < Director > > ( "/api/leadership/directors" ) ;
220
+ var directors = await _httpClient . GetFromJsonAsync < IEnumerable < Director > > ( "/api/leadership/directors" , TestContext . Current . CancellationToken ) ;
221
221
222
222
Assert . NotNull ( directors ) ;
223
223
Assert . Empty ( directors ) ;
@@ -226,7 +226,7 @@ public async Task Leadership_GetDirectors()
226
226
[ Fact ]
227
227
public async Task Photos_GetAlbums ( )
228
228
{
229
- var albums = await _httpClient . GetFromJsonAsync < IEnumerable < Album > > ( "/api/photos/albums" ) ;
229
+ var albums = await _httpClient . GetFromJsonAsync < IEnumerable < Album > > ( "/api/photos/albums" , TestContext . Current . CancellationToken ) ;
230
230
231
231
Assert . NotNull ( albums ) ;
232
232
Assert . Empty ( albums ) ;
@@ -235,7 +235,7 @@ public async Task Photos_GetAlbums()
235
235
[ Fact ]
236
236
public async Task Photos_GetAlbumById_404 ( )
237
237
{
238
- using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } ") ;
238
+ using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } ", TestContext . Current . CancellationToken ) ;
239
239
240
240
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
241
241
}
@@ -245,7 +245,7 @@ public async Task Photos_GetPhotoById_InvalidId_400()
245
245
{
246
246
string notAnObjectId = Random . Shared . Next ( ) . ToString ( ) ;
247
247
248
- using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } /photos/{ notAnObjectId } ") ;
248
+ using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } /photos/{ notAnObjectId } ", TestContext . Current . CancellationToken ) ;
249
249
250
250
Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
251
251
}
@@ -255,7 +255,7 @@ public async Task Photos_GetPhotoById_UnknownId_404()
255
255
{
256
256
string objectId = ObjectId . GenerateNewId ( ) . ToString ( ) ;
257
257
258
- using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } /photos/{ objectId } ") ;
258
+ using var response = await _httpClient . GetAsync ( $ "/api/photos/albums/{ Random . Shared . Next ( ) } /photos/{ objectId } ", TestContext . Current . CancellationToken ) ;
259
259
260
260
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
261
261
}
0 commit comments