diff --git a/Directory.Packages.props b/Directory.Packages.props index a935239..93ae785 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,8 +9,8 @@ - - + + @@ -20,10 +20,10 @@ - + - + diff --git a/src/NoPlan.Api/Endpoints/V1/ToDos/GetAllToDosEndpoint.cs b/src/NoPlan.Api/Endpoints/V1/ToDos/GetAllToDosEndpoint.cs index b321291..6af90d4 100644 --- a/src/NoPlan.Api/Endpoints/V1/ToDos/GetAllToDosEndpoint.cs +++ b/src/NoPlan.Api/Endpoints/V1/ToDos/GetAllToDosEndpoint.cs @@ -1,12 +1,11 @@ using Microsoft.AspNetCore.Http.HttpResults; using NoPlan.Api.Features.ToDos; using NoPlan.Api.Mappers; -using NoPlan.Contracts.Requests.V1.ToDos; using NoPlan.Contracts.Responses.V1.ToDos; namespace NoPlan.Api.Endpoints.V1.ToDos; -public sealed class GetAllToDosEndpoint(IToDoService toDoService) : Endpoint> +public sealed class GetAllToDosEndpoint(IToDoService toDoService) : Endpoint> { public override void Configure() { @@ -15,6 +14,6 @@ public override void Configure() Policies(AuthorizationPolicies.Users); } - public override async Task> ExecuteAsync(GetAllToDosRequest req, CancellationToken ct) => + public override async Task> ExecuteAsync(EmptyRequest req, CancellationToken ct) => TypedResults.Ok((await toDoService.GetAllAsync(User.GetId(), ct)).ToResponse()); } diff --git a/src/NoPlan.Contracts/Requests/V1/ToDos/GetAllToDosRequest.cs b/src/NoPlan.Contracts/Requests/V1/ToDos/GetAllToDosRequest.cs deleted file mode 100644 index 92803aa..0000000 --- a/src/NoPlan.Contracts/Requests/V1/ToDos/GetAllToDosRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace NoPlan.Contracts.Requests.V1.ToDos; - -public sealed record GetAllToDosRequest; diff --git a/tests/NoPlan.Api.Tests.Integration/EndpointCollection.cs b/tests/NoPlan.Api.Tests.Integration/EndpointCollection.cs new file mode 100644 index 0000000..cacd448 --- /dev/null +++ b/tests/NoPlan.Api.Tests.Integration/EndpointCollection.cs @@ -0,0 +1,4 @@ +namespace NoPlan.Api.Tests.Integration; + +[CollectionDefinition(nameof(EndpointCollection))] +public class EndpointCollection; diff --git a/tests/NoPlan.Api.Tests.Integration/Endpoints/V1/ToDos/GetAllToDosEndpointTests.cs b/tests/NoPlan.Api.Tests.Integration/Endpoints/V1/ToDos/GetAllToDosEndpointTests.cs index bf3a10c..d1cf259 100644 --- a/tests/NoPlan.Api.Tests.Integration/Endpoints/V1/ToDos/GetAllToDosEndpointTests.cs +++ b/tests/NoPlan.Api.Tests.Integration/Endpoints/V1/ToDos/GetAllToDosEndpointTests.cs @@ -17,10 +17,11 @@ public async Task HandleAsync_ShouldReturn200AndToDos_WhenUserIsAuthenticated() await AuthenticatedClientClient.POSTAsync(createToDoRequest); } - var request = new GetAllToDosRequest(); + var request = new EmptyRequest(); // Act - var (response, result) = await AuthenticatedClientClient.GETAsync(request); + var (response, result) = + await AuthenticatedClientClient.GETAsync(request); // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); @@ -31,10 +32,11 @@ public async Task HandleAsync_ShouldReturn200AndToDos_WhenUserIsAuthenticated() public async Task HandleAsync_ShouldReturn401_WhenUserIsNotAuthenticated() { // Arrange - var request = new GetAllToDosRequest(); + var request = new EmptyRequest(); // Act - var (response, result) = await AnonymousClient.GETAsync(request); + var (response, result) = + await AnonymousClient.GETAsync(request); // Assert response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); diff --git a/tests/NoPlan.Api.Tests.Integration/TestBases/EndpointTestBase.cs b/tests/NoPlan.Api.Tests.Integration/TestBases/EndpointTestBase.cs index 8e26008..4134fb8 100644 --- a/tests/NoPlan.Api.Tests.Integration/TestBases/EndpointTestBase.cs +++ b/tests/NoPlan.Api.Tests.Integration/TestBases/EndpointTestBase.cs @@ -1,5 +1,6 @@ namespace NoPlan.Api.Tests.Integration.TestBases; +[Collection(nameof(EndpointCollection))] public class EndpointTestBase(NoPlanApiFactory factory) : IAsyncLifetime, IClassFixture { protected HttpClient AuthenticatedClientClient { get; private set; } = null!;