Tests/Identity.Infrastructure.Tests/Services/IdentityServiceTests.cs
/// <summary>
/// Given not null request
/// and unassignment operation is done successfully
/// when unassigning a user from a role
/// Return succcess message
/// </summary>
Given not null request
and unassignment operation is done successfully
when unassigning a user from a role
Return succcess message
Given not null request and unassignment operation is done successfully when unassigning a user from a role Return succcess message
[Fact]
        public async Task UnassignRoleToUserAsync_RequestNotNull_SuccessfulAssignment_ReturnSuccessMessage()
        {
            UserRoleAssignmentRequest request = new UserRoleAssignmentRequest
            {
                Login = "nelson",
                RoleName = "bully"
            };
            User identityUser = new User
            {
                UserName = request.Login
            };
            _userManagerMock.Setup(mock => mock.FindByNameAsync(request.Login)).ReturnsAsync(identityUser);
            _userManagerMock.Setup(mock => mock.RemoveFromRoleAsync(identityUser, request.RoleName)).ReturnsAsync(
                IdentityResult.Success);
            ResultMessage resultMessage = await _identityService.UnassignRoleToUserAsync(request).ConfigureAwait(false);
            Assert.NotNull(resultMessage);
            Assert.True(resultMessage.OperationStatus);
        }
[ Fact ] public async Task UnassignRoleToUserAsync_RequestNotNull_SuccessfulAssignment_ReturnSuccessMessage ( ) { UserRoleAssignmentRequest request = new UserRoleAssignmentRequest { Login = " " , RoleName = " " } ; User identityUser = new User { UserName = request . Login } ; _userManagerMock . Setup ( mock => mock . FindByNameAsync ( request . Login ) ) . ReturnsAsync ( identityUser ) ; _userManagerMock . Setup ( mock => mock . RemoveFromRoleAsync ( identityUser , request . RoleName ) ) . ReturnsAsync ( IdentityResult . Success ) ; ResultMessage resultMessage = await _identityService . UnassignRoleToUserAsync ( request ) . ConfigureAwait ( false ) ; Assert . NotNull ( resultMessage ) ; Assert . True ( resultMessage . OperationStatus ) ; }
Given not null request
and unassignment operation is done successfully
when unassigning a user from a role
Return succcess message
Given not null request and unassignment operation is done successfully when unassigning a user from a role Return succcess message
// Arrange // Act // Assert