public void TryToChangePasswordWithWrongData() { var login = "******"; var mock = new Mock<IUserService>(); mock.Setup(m => m.FindByLogin(login)).Returns(new User { Login = "******" }); var target = new UserChangePasswordViewModelValidator(mock.Object, login); var changePassword = new UserChangePasswordViewModel { OldPassword = "******", NewPassword = "******", NewPasswordRepeated = "123457", }; var result = target.Validate(changePassword); result.Errors.Count.Should().Be(3); result.Errors[0].ErrorMessage.Should().Be("'Senha Atual' inválida."); result.Errors[1].ErrorMessage.Should().Be("As senhas informadas devem ser iguais."); result.Errors[2].ErrorMessage.Should().Be("As senhas informadas devem ser iguais."); }
public void TryToChangePasswordWithValidData() { var login = "******"; var mock = new Mock<IUserService>(); mock.Setup(m => m.FindByLogin(login)).Returns(new User { Login = "******", Password = PasswordHash.GetMD5Hash("1234") }); var target = new UserChangePasswordViewModelValidator(mock.Object, login); var changePassword = new UserChangePasswordViewModel { OldPassword = "******", NewPassword = "******", NewPasswordRepeated = "123456", }; var result = target.Validate(changePassword); result.Errors.Count.Should().Be(0); }
public void TryToChangePasswordWithoutData() { var mock = new Mock<IUserService>(); var target = new UserChangePasswordViewModelValidator(mock.Object, "pops.pops"); var result = target.Validate(new UserChangePasswordViewModel()); result.Errors.Count.Should().Be(3); result.Errors[0].ErrorMessage.Should().Be("'Senha Atual' deve ser preenchido."); result.Errors[1].ErrorMessage.Should().Be("'Senha' deve ser preenchido."); result.Errors[2].ErrorMessage.Should().Be("'Repetir Senha' deve ser preenchido."); }