Skip to content

Commit

Permalink
expose pagesize
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsonax committed May 25, 2024
1 parent 7649542 commit d750eb8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GetEmployees : TestBase
public async Task? GetEmployees_NoEmployees_ReturnsEmptyPage()
{
//Act
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(1);
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(1, 10);

//Assert
await response.AssertStatusCode(HttpStatusCode.OK);
Expand Down Expand Up @@ -37,7 +37,7 @@ public async Task GetEmployees_FirstPage_ReturnsExpectedEmployees()
});

//Act
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(1);
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(1, 10);

//Assert
await response.AssertStatusCode(HttpStatusCode.OK);
Expand Down Expand Up @@ -70,7 +70,7 @@ public async Task GetEmployees_SecondPage_ReturnsExpectedEmployees()
});

//Act
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(2);
var response = await Sut.CreateClientFor<IEmployeeApiClient>(ClaimConstants.ReadEmployeesRole).GetEmployees(2, 10);

//Assert
await response.AssertStatusCode(HttpStatusCode.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IEmployeeApiClient
Task<HttpResponseMessage> GetEmployeeById(Guid id);

[Get("/employees?page={page}")]
Task<HttpResponseMessage> GetEmployees(int page);
Task<HttpResponseMessage> GetEmployees(int page, int pageSize);

[Post("/employees")]
Task<HttpResponseMessage> CreateEmployee(CreateEmployeeRequest createEmployeeRequest);
Expand Down
4 changes: 2 additions & 2 deletions CleanAspCore/Endpoints/Employees/GetEmployees.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace CleanAspCore.Endpoints.Employees;

internal static class GetEmployees
{
internal static async Task<Ok<PagedList<GetEmployeeResponse>>> Handle(HrContext context, [FromQuery] int page, CancellationToken cancellationToken)
internal static async Task<Ok<PagedList<GetEmployeeResponse>>> Handle(HrContext context, [FromQuery] int page, [FromQuery] int pageSize, CancellationToken cancellationToken)
{
var result = await context.Employees
.OrderBy(x => x.FirstName)
.Select(x => x.ToDto())
.ToPagedListAsync(page, 10, cancellationToken);
.ToPagedListAsync(page, pageSize, cancellationToken);
return TypedResults.Ok(result);
}

Expand Down

0 comments on commit d750eb8

Please sign in to comment.