/// <summary> /// Method to update users using the Commands /// </summary> /// <param name="user">User to be updated</param> /// <returns>User</returns> public User UpdateUser(User user) { try { Command <Entity, Entity> CommandUpdateUser; CommandUpdateUser = FactoryCommand.GetCommandUpdateUser(); return((User)CommandUpdateUser.Execute(user)); } catch (Exception e) { Command <Exception, bool> CommandCreateLog; CommandCreateLog = FactoryCommand.GetCommandCreateLog(); CommandCreateLog.Execute(e); } return(null); }
public void execute_givenAPassword_GenerateEncryptedPasswordAndKey() { Func <IUnitOfWork> _uow; var _repository = userRepositoryCommands(out _uow); var _userTest = Builder <User> .CreateNew().Build(); var _passwordUser = _userTest.Password; var size = 128; var _keyGenerator = new UserKeyGenerator(new RandomKeyGenerator(), size); var encryptService = new CryptoService(_keyGenerator, (x) => new DefaultHmacProvider(x)); var passwordEncrypted = encryptService.getEncryptedText(_passwordUser); var userKey = _keyGenerator.getKey(); var command = new CommandUpdateUser(encryptService, _repository, _uow); command.execute(_userTest); Mock.Get(_repository).Verify(x => x.update(It.Is <User>(z => z.Password == passwordEncrypted && z.UserKey == userKey))); }