protected override void Context() { base.Context(); _changePasswordRequest = new ChangePasswordRequest { Username = "******", CurrentPassword = "******", NewPassword = "******", }; EncryptedCurrentPasswordReturnedFromCryptographyService = "current encrypted password"; CryptographyService.Stub(x => x.Encrypt(Arg<string>.Is.Equal(_changePasswordRequest.CurrentPassword))) .Return(EncryptedCurrentPasswordReturnedFromCryptographyService); _encryptedNewPasswordReturnedFromCryptographyService = "new encrypted password"; CryptographyService.Stub(x => x.Encrypt(Arg<string>.Is.Equal(_changePasswordRequest.NewPassword))) .Return(_encryptedNewPasswordReturnedFromCryptographyService); AccountRepository.Stub( x => x.ChangePassword(Arg<string>.Is.Equal(_changePasswordRequest.Username), Arg<string>.Is.Equal(EncryptedCurrentPasswordReturnedFromCryptographyService), Arg<string>.Is.Equal(_encryptedNewPasswordReturnedFromCryptographyService))) .WhenCalled(x => _usernamePassedToRepository = x.Arguments[0].ToString()) .WhenCalled(x => _currentPasswordPassedToRepository = x.Arguments[1].ToString()) .WhenCalled(x => _newPasswordPassedToRepository = x.Arguments[2].ToString()); }
public void ChangePassword(ChangePasswordRequest changePasswordRequest) { string encrypedCurrentPassword = _cryptographyService.Encrypt(changePasswordRequest.CurrentPassword); string encryptedNewPassword = _cryptographyService.Encrypt(changePasswordRequest.NewPassword); _accountRepository.ChangePassword(changePasswordRequest.Username, encrypedCurrentPassword, encryptedNewPassword); }
protected override void Context() { Username = "******"; base.Context(); AccountService.Stub( x => x.ChangePassword(Arg<ChangePasswordRequest>.Is.Anything)) .WhenCalled(x => _changePasswordRequestPassedToAccountService = x.Arguments[0] as ChangePasswordRequest); _expectedRequest = new ChangePasswordRequest { Username = Username, CurrentPassword = CurrentPassword, NewPassword = NewPassword, }; }