Tests/Identity.Infrastructure.Tests/Services/IdentityServiceTests.cs
/// <summary>
/// Given not null request
/// and password update is sucessful
/// when updating user password
/// return success message
/// </summary>
Given not null request
and password update is sucessful
when updating user password
return success message
Given not null request and password update is sucessful when updating user password return success message
[Fact]
        public async Task UpdateUserPasswordAsync_RequestNotNull_SuccessfulUpdate_ReturnSuccessMessage()
        {
            PasswordInitializationRequest request = new PasswordInitializationRequest
            {
                Login = "Homer",
                OldPassword = "Hold my beer",
                NewPassword = "thank you moe"
            };
            User identityUser = new User
            {
                UserName = request.Login
            };
            _userManagerMock.Setup(mock => mock.FindByNameAsync(request.Login)).ReturnsAsync(identityUser);
            _userManagerMock.Setup(mock => mock.ChangePasswordAsync(identityUser, request.OldPassword, request.NewPassword))
                .ReturnsAsync(IdentityResult.Success);
            ResultMessage resultMessage = await _identityService.UpdateUserPasswordAsync(request).ConfigureAwait(false);
            Assert.NotNull(resultMessage);
            Assert.True(resultMessage.OperationStatus);
        }
[ Fact ] public async Task UpdateUserPasswordAsync_RequestNotNull_SuccessfulUpdate_ReturnSuccessMessage ( ) { PasswordInitializationRequest request = new PasswordInitializationRequest { Login = " " , OldPassword = " " , NewPassword = " " } ; User identityUser = new User { UserName = request . Login } ; _userManagerMock . Setup ( mock => mock . FindByNameAsync ( request . Login ) ) . ReturnsAsync ( identityUser ) ; _userManagerMock . Setup ( mock => mock . ChangePasswordAsync ( identityUser , request . OldPassword , request . NewPassword ) ) . ReturnsAsync ( IdentityResult . Success ) ; ResultMessage resultMessage = await _identityService . UpdateUserPasswordAsync ( request ) . ConfigureAwait ( false ) ; Assert . NotNull ( resultMessage ) ; Assert . True ( resultMessage . OperationStatus ) ; }
Given not null request
and password update is sucessful
when updating user password
return success message
Given not null request and password update is sucessful when updating user password return success message
// Arrange // Act // Assert