Tests/Identity.Infrastructure.Tests/Services/IdentityServiceTests.cs
/// <summary>
/// Given request is not null
/// And user isn't admin
/// and deletion is done successfully
/// When deleting user
/// return success message
/// </summary>
Given request is not null
And user isn't admin
and deletion is done successfully
When deleting user
return success message
Given request is not null And user isn ' t admin and deletion is done successfully When deleting user return success message
[Fact]
        public async Task DeleteUserAsync_NotNullRequest_UserNotAdmin_OkDeletion_ReturnSuccessMessage()
        {
            DeleteUserRequest request = new DeleteUserRequest
            {
                Login = "haw-haw"
            };
            User identityUser = new User
            {
                UserName = request.Login
            };
            _userManagerMock.Setup(mock => mock.FindByNameAsync(request.Login)).ReturnsAsync(identityUser);
            _userManagerMock.Setup(mock => mock.GetRolesAsync(identityUser)).ReturnsAsync(
                new List<string> { "hawRole" });
            _userManagerMock.Setup(mock => mock.DeleteAsync(identityUser)).ReturnsAsync(IdentityResult.Success);
            ResultMessage resultMessage = await _identityService.DeleteUserAsync(request).ConfigureAwait(false);
            Assert.NotNull(resultMessage);
            Assert.True(resultMessage.OperationStatus);
        }
[ Fact ] public async Task DeleteUserAsync_NotNullRequest_UserNotAdmin_OkDeletion_ReturnSuccessMessage ( ) { DeleteUserRequest request = new DeleteUserRequest { Login = " " } ; User identityUser = new User { UserName = request . Login } ; _userManagerMock . Setup ( mock => mock . FindByNameAsync ( request . Login ) ) . ReturnsAsync ( identityUser ) ; _userManagerMock . Setup ( mock => mock . GetRolesAsync ( identityUser ) ) . ReturnsAsync ( new List < string > { " " } ) ; _userManagerMock . Setup ( mock => mock . DeleteAsync ( identityUser ) ) . ReturnsAsync ( IdentityResult . Success ) ; ResultMessage resultMessage = await _identityService . DeleteUserAsync ( request ) . ConfigureAwait ( false ) ; Assert . NotNull ( resultMessage ) ; Assert . True ( resultMessage . OperationStatus ) ; }
Given request is not null
And user isn't admin
and deletion is done successfully
When deleting user
return success message
Given request is not null And user isn ' t admin and deletion is done successfully When deleting user return success message
// Arrange // Act // Assert