99
1010namespace exercise . tests . IntegrationTests
1111{
12+ /// <summary>
13+ /// Integration tests exercising the user management endpoints end-to-end via the API surface.
14+ /// </summary>
1215 [ TestFixture ]
1316 public class UserTests
1417 {
@@ -30,7 +33,13 @@ public void TearDown()
3033 _factory . Dispose ( ) ;
3134 }
3235
33- // ad test cases for approved usernames, emails
36+ /// <summary>
37+ /// Confirms that valid registration payloads yield an HTTP 201 Created response.
38+ /// </summary>
39+ /// <remarks>Test cases come from <see cref="UserTestCases.ValidRegisterCases"/> and are uniquified at runtime to avoid clashes.</remarks>
40+ /// <param name="username">The base username supplied by the data source.</param>
41+ /// <param name="email">The base email supplied by the data source.</param>
42+ /// <param name="password">The password candidate to register with.</param>
3443 [ Test , TestCaseSource ( typeof ( UserTestCases ) , nameof ( UserTestCases . ValidRegisterCases ) ) ]
3544 public async Task Register_success ( string username , string email , string password )
3645 {
@@ -62,6 +71,13 @@ public async Task Register_success(string username, string email, string passwor
6271 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . Created ) ) ;
6372 }
6473
74+ /// <summary>
75+ /// Verifies the registration endpoint rejects malformed payloads with non-Created responses.
76+ /// </summary>
77+ /// <remarks>Inputs are provided by <see cref="UserTestCases.InvalidRegisterCases"/>.</remarks>
78+ /// <param name="username">The attempted username for registration.</param>
79+ /// <param name="email">The attempted email for registration.</param>
80+ /// <param name="password">The password candidate under test.</param>
6581 [ Test , TestCaseSource ( typeof ( UserTestCases ) , nameof ( UserTestCases . InvalidRegisterCases ) ) ]
6682 public async Task Register_Failure ( string username , string email , string password )
6783 {
@@ -96,6 +112,12 @@ public async Task Register_Failure(string username, string email, string passwor
96112 }
97113
98114
115+ /// <summary>
116+ /// Ensures valid credentials receive an HTTP 200 response and a token payload.
117+ /// </summary>
118+ /// <remarks>Credentials are sourced from <see cref="UserTestCases.ValidLoginCases"/>.</remarks>
119+ /// <param name="email">The email address to authenticate with.</param>
120+ /// <param name="password">The password paired with the supplied email.</param>
99121 [ Test , TestCaseSource ( typeof ( UserTestCases ) , nameof ( UserTestCases . ValidLoginCases ) ) ]
100122 public async Task Login_success ( string email , string password )
101123 {
@@ -127,6 +149,12 @@ public async Task Login_success(string email, string password)
127149 Assert . That ( message [ "data" ] [ "token" ] , Is . Not . Null ) ;
128150 }
129151
152+ /// <summary>
153+ /// Asserts that invalid login attempts fail with the expected HTTP status and message.
154+ /// </summary>
155+ /// <remarks>Negative credential combinations come from <see cref="UserTestCases.InvalidLoginCases"/>.</remarks>
156+ /// <param name="email">The incorrect email supplied to the login endpoint.</param>
157+ /// <param name="password">The incorrect password paired with the email.</param>
130158 [ Test , TestCaseSource ( typeof ( UserTestCases ) , nameof ( UserTestCases . InvalidLoginCases ) ) ]
131159 public async Task Login_failure ( string email , string password )
132160 {
@@ -161,6 +189,9 @@ public async Task Login_failure(string email, string password)
161189
162190 }
163191
192+ /// <summary>
193+ /// Validates that a PATCH with complete, valid fields updates an existing user successfully.
194+ /// </summary>
164195 [ Test ]
165196 public async Task UpdateUserSuccess ( )
166197 {
@@ -181,6 +212,9 @@ public async Task UpdateUserSuccess()
181212 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . OK ) ) ;
182213 }
183214
215+ /// <summary>
216+ /// Ensures PATCH requests with no mutable fields return a bad request response.
217+ /// </summary>
184218 [ Test ]
185219 public async Task UpdateUserNullFieldsOnly ( )
186220 {
@@ -195,6 +229,9 @@ public async Task UpdateUserNullFieldsOnly()
195229 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
196230 }
197231
232+ /// <summary>
233+ /// Confirms the API rejects usernames that violate allowed formatting rules.
234+ /// </summary>
198235 [ Test ]
199236 public async Task UpdateUserInvalidUsername ( )
200237 {
@@ -212,6 +249,9 @@ public async Task UpdateUserInvalidUsername()
212249 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
213250 }
214251
252+ /// <summary>
253+ /// Confirms GitHub username updates honor the same validation rules as the standalone validator.
254+ /// </summary>
215255 [ Test ]
216256 public async Task UpdateUserInvalidGitHubUsername ( )
217257 {
@@ -229,6 +269,9 @@ public async Task UpdateUserInvalidGitHubUsername()
229269 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
230270 }
231271
272+ /// <summary>
273+ /// Verifies email updates are blocked when the address fails format validation.
274+ /// </summary>
232275 [ Test ]
233276 public async Task UpdateUserInvalidEmail ( )
234277 {
@@ -246,6 +289,9 @@ public async Task UpdateUserInvalidEmail()
246289 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
247290 }
248291
292+ /// <summary>
293+ /// Confirms passwords that do not meet the complexity requirements are rejected on update.
294+ /// </summary>
249295 [ Test ]
250296 public async Task UpdateUserInvalidPassword ( )
251297 {
@@ -263,6 +309,9 @@ public async Task UpdateUserInvalidPassword()
263309 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
264310 }
265311
312+ /// <summary>
313+ /// Ensures role updates outside the defined enum range produce a bad request.
314+ /// </summary>
266315 [ Test ]
267316 public async Task UpdateUserInvalidRole ( )
268317 {
@@ -280,6 +329,9 @@ public async Task UpdateUserInvalidRole()
280329 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
281330 }
282331
332+ /// <summary>
333+ /// Verifies the API prevents changing a username to one that is already in use.
334+ /// </summary>
283335 [ Test ]
284336 public async Task UpdateUserUsernameExists ( )
285337 {
@@ -297,6 +349,9 @@ public async Task UpdateUserUsernameExists()
297349 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
298350 }
299351
352+ /// <summary>
353+ /// Verifies the API prevents reusing an existing GitHub username value.
354+ /// </summary>
300355 [ Test ]
301356 public async Task UpdateUserGitHubUsernameExists ( )
302357 {
@@ -314,6 +369,9 @@ public async Task UpdateUserGitHubUsernameExists()
314369 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
315370 }
316371
372+ /// <summary>
373+ /// Verifies the API prevents reusing an existing email address value.
374+ /// </summary>
317375 [ Test ]
318376 public async Task UpdateUserEmailExists ( )
319377 {
@@ -331,6 +389,11 @@ public async Task UpdateUserEmailExists()
331389 Assert . That ( response . StatusCode , Is . EqualTo ( HttpStatusCode . BadRequest ) ) ;
332390 }
333391
392+ /// <summary>
393+ /// Ensures retrieving users by id returns 200 for known users and 404 for missing ones.
394+ /// </summary>
395+ /// <param name="id">The user id sent to the endpoint.</param>
396+ /// <param name="responseStatus">The expected HTTP status code.</param>
334397 [ TestCase ( "1" , HttpStatusCode . OK ) ]
335398 [ TestCase ( "10000000" , HttpStatusCode . NotFound ) ]
336399 public async Task GetUserByIdTest ( string id , HttpStatusCode responseStatus )
0 commit comments