Tests/Identity.Infrastructure.Tests/Services/IdentityServiceTests.cs
/// <summary>
/// Given not null request
/// And user role is admin
/// when initializing user password
/// return error message
/// </summary>
Given not null request
And user role is admin
when initializing user password
return error message
Given not null request And user role is admin when initializing user password return error message
[Fact]
        public async Task InitializeUserPassword_NotNullRequest_AdminRole_ReturnErrorMessage()
        {
            PasswordInitializationRequest request = new PasswordInitializationRequest
            {
                Login = "skinner",
                NewPassword = "skinnerIsNotWienner",
                OldPassword = "skinnerIsWienner"
            };
            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>
                { "ADMINISTRATOR" });
            ResultMessage result = await _identityService.InitializeUserPasswordAsync(request).ConfigureAwait(false);
            Assert.NotNull(result);
            Assert.False(result.OperationStatus);
            Assert.Equal(MessageResources.ReinitializeAdminPassword,
                result.ErrorMessages.First());
        }
[ Fact ] public async Task InitializeUserPassword_NotNullRequest_AdminRole_ReturnErrorMessage ( ) { PasswordInitializationRequest request = new PasswordInitializationRequest { Login = " " , NewPassword = " " , OldPassword = " " } ; 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 > { " " } ) ; ResultMessage result = await _identityService . InitializeUserPasswordAsync ( request ) . ConfigureAwait ( false ) ; Assert . NotNull ( result ) ; Assert . False ( result . OperationStatus ) ; Assert . Equal ( MessageResources . ReinitializeAdminPassword , result . ErrorMessages . First ( ) ) ; }
Given not null request
And user role is admin
when initializing user password
return error message
Given not null request And user role is admin when initializing user password return error message
// Arrange // Act // Assert