public async Task Should_return_error_when_find_by_email_returns_null() { fakeAccountRepository.Setup(x => x.FindByEmailAsync(It.IsAny <string>())) .ReturnsAsync(null as Account); var handler = new ForgotPasswordAccountHandler(fakeAccountRepository.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.True(result.Invalid); Assert.Equal("Não foi possível resetar a senha.", result.Message); }
public async Task Should_return_error_when_generate_password_reset_token_returns_false() { fakeAccountRepository.Setup(x => x.FindByEmailAsync(It.IsAny <string>())) .ReturnsAsync(fakeAccount.Object); fakeAccountRepository.Setup(x => x.IsEmailConfirmedAsync(It.IsAny <Account>())) .ReturnsAsync(true); fakeAccountRepository.Setup(x => x.GeneratePasswordResetTokenAsync(It.IsAny <Account>())) .ReturnsAsync(string.Empty); var handler = new ForgotPasswordAccountHandler(fakeAccountRepository.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.True(result.Invalid); Assert.Equal("Não foi possível resetar a senha.", result.Message); }
public async Task Should_not_return_error() { fakeAccountRepository.Setup(x => x.FindByEmailAsync(It.IsAny <string>())) .ReturnsAsync(fakeAccount.Object); fakeAccountRepository.Setup(x => x.IsEmailConfirmedAsync(It.IsAny <Account>())) .ReturnsAsync(true); fakeAccountRepository.Setup(x => x.GeneratePasswordResetTokenAsync(It.IsAny <Account>())) .ReturnsAsync("code"); var handler = new ForgotPasswordAccountHandler(fakeAccountRepository.Object); var result = await handler.Handle(command, CancellationToken.None); Assert.True(result.Valid); Assert.Equal("Para trocar a sua senha acesse o link que foi enviado para o seu e-mail.", result.Message); }