diff --git a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetAllUsersTestFixture.cs b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetAllUsersTestFixture.cs index 3357845..9e22915 100644 --- a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetAllUsersTestFixture.cs +++ b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetAllUsersTestFixture.cs @@ -36,4 +36,22 @@ public sealed class GetAllUsersTestFixture : QueryHandlerBaseFixture .Setup(x => x.GetAllNoTracking()) .Returns(query); } + + public void SetupDeletedUserAsync() + { + var user = new Mock(() => + new User( + ExistingUserId, + "max@mustermann.com", + "Max", + "Mustermann")); + + user.Object.Delete(); + + var query = new[] { user.Object }.AsQueryable().BuildMock(); + + UserRepository + .Setup(x => x.GetAllNoTracking()) + .Returns(query); + } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs index d50699f..404f699 100644 --- a/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs +++ b/CleanArchitecture.Application.Tests/Fixtures/Queries/Users/GetUserByIdTestFixture.cs @@ -36,4 +36,22 @@ public sealed class GetUserByIdTestFixture : QueryHandlerBaseFixture .Setup(x => x.GetAllNoTracking()) .Returns(query); } + + public void SetupDeletedUserAsync() + { + var user = new Mock(() => + new User( + ExistingUserId, + "max@mustermann.com", + "Max", + "Mustermann")); + + user.Object.Delete(); + + var query = new[] { user.Object }.AsQueryable().BuildMock(); + + UserRepository + .Setup(x => x.GetAllNoTracking()) + .Returns(query); + } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Fixtures/Services/UserServiceTestFixture.cs b/CleanArchitecture.Application.Tests/Fixtures/Services/UserServiceTestFixture.cs deleted file mode 100644 index 98ebbd3..0000000 --- a/CleanArchitecture.Application.Tests/Fixtures/Services/UserServiceTestFixture.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CleanArchitecture.Application.Tests.Fixtures.Services; - -public sealed class UserServiceTestFixture -{ - -} \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs index 44af10e..f1ec70e 100644 --- a/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs @@ -26,5 +26,17 @@ public sealed class GetAllUsersQueryHandlerTests result.FirstOrDefault()!.Id.Should().Be(_fixture.ExistingUserId); } - // Add Test for deleted user + [Fact] + public async Task Should_Not_Get_Deleted_Users() + { + _fixture.SetupDeletedUserAsync(); + + var result = await _fixture.Handler.Handle( + new(), + default); + + _fixture.VerifyNoDomainNotification(); + + result.Should().BeEmpty(); + } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs index b4fa2bd..a65da4c 100644 --- a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs @@ -45,5 +45,20 @@ public sealed class GetUserByIdQueryHandlerTests result.Should().BeNull(); } - // Add Test for deleted user + [Fact] + public async Task Should_Not_Get_Deleted_User() + { + _fixture.SetupDeletedUserAsync(); + + var result = await _fixture.Handler.Handle( + new(_fixture.ExistingUserId, false), + default); + + _fixture.VerifyExistingNotification( + nameof(GetUserByIdQuery), + ErrorCodes.ObjectNotFound, + $"User with id {_fixture.ExistingUserId} could not be found"); + + result.Should().BeNull(); + } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Services/UserServiceTests.cs b/CleanArchitecture.Application.Tests/Services/UserServiceTests.cs deleted file mode 100644 index 1e86b71..0000000 --- a/CleanArchitecture.Application.Tests/Services/UserServiceTests.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CleanArchitecture.Application.Tests.Services; - -public sealed class UserServiceTests -{ - -} \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj index 8d36f4a..5f128a0 100644 --- a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj +++ b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj @@ -31,8 +31,4 @@ - - - - diff --git a/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj b/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj index fa76384..1f914a1 100644 --- a/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj +++ b/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj @@ -6,19 +6,19 @@ - - + + - - + + - + diff --git a/Todo.txt b/Todo.txt index ebb0118..3931b92 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,4 +1,2 @@ - Remove warnings and apply suggestions - Add authentication and authorization -- Utility integration tests -- Queryhandler tests for deleted users \ No newline at end of file