Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exercise.tests/IntegrationTests/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
// Assert
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}

Check warning on line 71 in exercise.tests/IntegrationTests/UserTests.cs

View workflow job for this annotation

GitHub Actions / build-and-test

The variable 'firstName' is assigned but its value is never used
[Test, TestCaseSource(typeof(UserTestCases), nameof(UserTestCases.InvalidRegisterCases))]

Check warning on line 72 in exercise.tests/IntegrationTests/UserTests.cs

View workflow job for this annotation

GitHub Actions / build-and-test

The variable 'lastName' is assigned but its value is never used
public async Task Register_Failure(string username, string email, string password)
{
var uniqueId = DateTime.UtcNow.ToString("yyMMddHHmmssffff");
Expand Down Expand Up @@ -343,5 +343,13 @@
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
}

[TestCase("1", HttpStatusCode.OK)]
[TestCase("10000000", HttpStatusCode.NotFound)]
public async Task GetUserByIdTest(string id, HttpStatusCode responseStatus)
{
var response = await _client.GetAsync($"/users/{id}");
Assert.That(response.StatusCode, Is.EqualTo(responseStatus));

}
}
}
6 changes: 4 additions & 2 deletions exercise.wwwapi/Endpoints/UserEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ private static IResult Login(LoginRequestDTO request, IRepository<User> service,

}
[ProducesResponseType(StatusCodes.Status200OK)]
public static async Task<IResult> GetUserById(int id)
public static async Task<IResult> GetUserById(IRepository<User> service, int id)
{
return TypedResults.Ok();
var user = service.GetById(id);
if (user == null) return TypedResults.NotFound();
return TypedResults.Ok(user);
}

[ProducesResponseType(StatusCodes.Status200OK)]
Expand Down