From 634047eff1101a68ad7576c23474e87b2d217bc1 Mon Sep 17 00:00:00 2001 From: Jimmy Vo Date: Thu, 17 Apr 2025 16:17:05 -0400 Subject: [PATCH] [PM-15621] Removed tests that are now handled in the validators. --- ...imedOrganizationUserAccountCommandTests.cs | 422 ------------------ 1 file changed, 422 deletions(-) diff --git a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteClaimedOrganizationUserAccountCommandTests.cs b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteClaimedOrganizationUserAccountCommandTests.cs index 6508148059..acff53521f 100644 --- a/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteClaimedOrganizationUserAccountCommandTests.cs +++ b/test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteClaimedOrganizationUserAccountCommandTests.cs @@ -44,214 +44,6 @@ public class DeleteClaimedOrganizationUserAccountCommandTests // .LogOrganizationUserEventAsync(organizationUser, EventType.OrganizationUser_Deleted); // } - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_WithUserNotFound_ThrowsException( - // SutProvider sutProvider, - // Guid organizationId, Guid organizationUserId) - // { - // // Arrange - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUserId) - // .Returns((OrganizationUser?)null); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationId, organizationUserId, null)); - - // // Assert - // Assert.Equal("Member not found.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_DeletingYourself_ThrowsException( - // SutProvider sutProvider, - // User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.User)] OrganizationUser organizationUser, - // Guid deletingUserId) - // { - // // Arrange - // organizationUser.UserId = user.Id = deletingUserId; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // sutProvider.GetDependency().GetByIdAsync(user.Id) - // .Returns(user); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, deletingUserId)); - - // // Assert - // Assert.Equal("You cannot delete yourself.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_WhenUserIsInvited_ThrowsException( - // SutProvider sutProvider, - // [OrganizationUser(OrganizationUserStatusType.Invited, OrganizationUserType.User)] OrganizationUser organizationUser) - // { - // // Arrange - // organizationUser.UserId = null; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, null)); - - // // Assert - // Assert.Equal("You cannot delete a member with Invited status.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_WhenCustomUserDeletesAdmin_ThrowsException( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Admin)] OrganizationUser organizationUser, - // Guid deletingUserId) - // { - // // Arrange - // organizationUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // sutProvider.GetDependency().GetByIdAsync(user.Id) - // .Returns(user); - - // sutProvider.GetDependency() - // .OrganizationCustom(organizationUser.OrganizationId) - // .Returns(true); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, deletingUserId)); - - // // Assert - // Assert.Equal("Custom users can not delete admins.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_DeletingOwnerWhenNotOwner_ThrowsException( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser organizationUser, - // Guid deletingUserId) - // { - // // Arrange - // organizationUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // sutProvider.GetDependency().GetByIdAsync(user.Id) - // .Returns(user); - - // sutProvider.GetDependency() - // .OrganizationOwner(organizationUser.OrganizationId) - // .Returns(false); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, deletingUserId)); - - // // Assert - // Assert.Equal("Only owners can delete other owners.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_DeletingLastConfirmedOwner_ThrowsException( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser organizationUser, - // Guid deletingUserId) - // { - // // Arrange - // organizationUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // sutProvider.GetDependency().GetByIdAsync(user.Id) - // .Returns(user); - - // sutProvider.GetDependency() - // .OrganizationOwner(organizationUser.OrganizationId) - // .Returns(true); - - // sutProvider.GetDependency() - // .HasConfirmedOwnersExceptAsync( - // organizationUser.OrganizationId, - // Arg.Is>(ids => ids.Contains(organizationUser.Id)), - // includeProvider: Arg.Any()) - // .Returns(false); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, deletingUserId)); - - // // Assert - // Assert.Equal("Organization must have at least one confirmed owner.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteUserAsync_WithUserNotManaged_ThrowsException( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.User)] OrganizationUser organizationUser) - // { - // // Arrange - // organizationUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetByIdAsync(organizationUser.Id) - // .Returns(organizationUser); - - // sutProvider.GetDependency().GetByIdAsync(user.Id) - // .Returns(user); - - // sutProvider.GetDependency() - // .GetUsersOrganizationClaimedStatusAsync(organizationUser.OrganizationId, Arg.Any>()) - // .Returns(new Dictionary { { organizationUser.Id, false } }); - - // // Act - // var exception = await Assert.ThrowsAsync(() => - // sutProvider.Sut.DeleteUserAsync(organizationUser.OrganizationId, organizationUser.Id, null)); - - // // Assert - // Assert.Equal("Member is not claimed by the organization.", exception.Message); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventAsync(Arg.Any(), Arg.Any(), Arg.Any()); - // } // [Theory] // [BitAutoData] @@ -293,222 +85,8 @@ public class DeleteClaimedOrganizationUserAccountCommandTests // && events.Count(e => e.Item1.Id == orgUser2.Id && e.Item2 == EventType.OrganizationUser_Deleted) == 1)); // } - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenUserNotFound_ReturnsErrorMessage( - // SutProvider sutProvider, - // Guid organizationId, - // Guid orgUserId) - // { - // // Act - // var result = await sutProvider.Sut.DeleteManyUsersAsync(organizationId, new[] { orgUserId }, null); - // // Assert - // Assert.Single(result); - // Assert.Equal(orgUserId, result.First().Item1); - // Assert.Contains("Member not found.", result.First().Item2); - // await sutProvider.GetDependency() - // .DidNotReceiveWithAnyArgs() - // .DeleteManyAsync(default); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenDeletingYourself_ReturnsErrorMessage( - // SutProvider sutProvider, - // User user, [OrganizationUser] OrganizationUser orgUser, Guid deletingUserId) - // { - // // Arrange - // orgUser.UserId = user.Id = deletingUserId; - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser }); - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Is>(ids => ids.Contains(user.Id))) - // .Returns(new[] { user }); - - // // Act - // var result = await sutProvider.Sut.DeleteManyUsersAsync(orgUser.OrganizationId, new[] { orgUser.Id }, deletingUserId); - - // // Assert - // Assert.Single(result); - // Assert.Equal(orgUser.Id, result.First().Item1); - // Assert.Contains("You cannot delete yourself.", result.First().Item2); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenUserIsInvited_ReturnsErrorMessage( - // SutProvider sutProvider, - // [OrganizationUser(OrganizationUserStatusType.Invited, OrganizationUserType.User)] OrganizationUser orgUser) - // { - // // Arrange - // orgUser.UserId = null; - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser }); - - // // Act - // var result = await sutProvider.Sut.DeleteManyUsersAsync(orgUser.OrganizationId, new[] { orgUser.Id }, null); - - // // Assert - // Assert.Single(result); - // Assert.Equal(orgUser.Id, result.First().Item1); - // Assert.Contains("You cannot delete a member with Invited status.", result.First().Item2); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenDeletingOwnerAsNonOwner_ReturnsErrorMessage( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser orgUser, - // Guid deletingUserId) - // { - // // Arrange - // orgUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser }); - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Is>(i => i.Contains(user.Id))) - // .Returns(new[] { user }); - - // sutProvider.GetDependency() - // .OrganizationOwner(orgUser.OrganizationId) - // .Returns(false); - - // var result = await sutProvider.Sut.DeleteManyUsersAsync(orgUser.OrganizationId, new[] { orgUser.Id }, deletingUserId); - - // Assert.Single(result); - // Assert.Equal(orgUser.Id, result.First().Item1); - // Assert.Contains("Only owners can delete other owners.", result.First().Item2); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenDeletingLastOwner_ReturnsErrorMessage( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser orgUser, - // Guid deletingUserId) - // { - // // Arrange - // orgUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser }); - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Is>(i => i.Contains(user.Id))) - // .Returns(new[] { user }); - - // sutProvider.GetDependency() - // .OrganizationOwner(orgUser.OrganizationId) - // .Returns(true); - - // sutProvider.GetDependency() - // .HasConfirmedOwnersExceptAsync(orgUser.OrganizationId, Arg.Any>(), Arg.Any()) - // .Returns(false); - - // // Act - // var result = await sutProvider.Sut.DeleteManyUsersAsync(orgUser.OrganizationId, new[] { orgUser.Id }, deletingUserId); - - // // Assert - // Assert.Single(result); - // Assert.Equal(orgUser.Id, result.First().Item1); - // Assert.Contains("Organization must have at least one confirmed owner.", result.First().Item2); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_WhenUserNotManaged_ReturnsErrorMessage( - // SutProvider sutProvider, User user, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.User)] OrganizationUser orgUser) - // { - // // Arrange - // orgUser.UserId = user.Id; - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser }); - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Is>(ids => ids.Contains(orgUser.UserId.Value))) - // .Returns(new[] { user }); - - // sutProvider.GetDependency() - // .GetUsersOrganizationClaimedStatusAsync(Arg.Any(), Arg.Any>()) - // .Returns(new Dictionary { { orgUser.Id, false } }); - - // // Act - // var result = await sutProvider.Sut.DeleteManyUsersAsync(orgUser.OrganizationId, new[] { orgUser.Id }, null); - - // // Assert - // Assert.Single(result); - // Assert.Equal(orgUser.Id, result.First().Item1); - // Assert.Contains("Member is not claimed by the organization.", result.First().Item2); - // await sutProvider.GetDependency().Received(0).DeleteAsync(Arg.Any()); - // await sutProvider.GetDependency().Received(0) - // .LogOrganizationUserEventsAsync(Arg.Any>()); - // } - - // [Theory] - // [BitAutoData] - // public async Task DeleteManyUsersAsync_MixedValidAndInvalidUsers_ReturnsAppropriateResults( - // SutProvider sutProvider, User user1, User user3, - // Guid organizationId, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.User)] OrganizationUser orgUser1, - // [OrganizationUser(OrganizationUserStatusType.Invited, OrganizationUserType.User)] OrganizationUser orgUser2, - // [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.User)] OrganizationUser orgUser3) - // { - // // Arrange - // orgUser1.UserId = user1.Id; - // orgUser2.UserId = null; - // orgUser3.UserId = user3.Id; - // orgUser1.OrganizationId = orgUser2.OrganizationId = orgUser3.OrganizationId = organizationId; - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Any>()) - // .Returns(new List { orgUser1, orgUser2, orgUser3 }); - - // sutProvider.GetDependency() - // .GetManyAsync(Arg.Is>(ids => ids.Contains(user1.Id) && ids.Contains(user3.Id))) - // .Returns(new[] { user1, user3 }); - - // sutProvider.GetDependency() - // .GetUsersOrganizationClaimedStatusAsync(organizationId, Arg.Any>()) - // .Returns(new Dictionary { { orgUser1.Id, true }, { orgUser3.Id, false } }); - - // // Act - // var results = await sutProvider.Sut.DeleteManyUsersAsync(organizationId, new[] { orgUser1.Id, orgUser2.Id, orgUser3.Id }, null); - - // // Assert - // Assert.Equal(3, results.Count()); - // Assert.Empty(results.First(r => r.Item1 == orgUser1.Id).Item2); - // Assert.Equal("You cannot delete a member with Invited status.", results.First(r => r.Item1 == orgUser2.Id).Item2); - // Assert.Equal("Member is not claimed by the organization.", results.First(r => r.Item1 == orgUser3.Id).Item2); - - // await sutProvider.GetDependency().Received(1).LogOrganizationUserEventsAsync( - // Arg.Is>(events => - // events.Count(e => e.Item1.Id == orgUser1.Id && e.Item2 == EventType.OrganizationUser_Deleted) == 1)); - // } }