public void CanLoadWaiterIfPasswordsMatch() { const string salt = "salt"; const string password = "******"; A.CallTo(() => passwordEncryptor.GenerateSalt()).Returns(salt); A.CallTo(() => passwordEncryptor.GenerateHash(password, salt)).Returns("cba"); var waiter = new Staff { UserAccount = new UserAccount { Password = password.ComputePBKDF2Hash(salt, passwordEncryptor), Salt = salt } }; A.CallTo(() => repository.FindBy <Staff>(a => a.UserAccount.Username == "a")) .WithAnyArguments() .Returns(new List <Staff> { waiter }); var result = staffDomainService.LoadStaff("a", password); Assert.IsTrue(result.IsNotNull()); }
/// <summary> /// Generates a new salt and encrypts the password /// </summary> public void EncrypPassword(IPasswordEncryptor passwordEncryptor) { Guard.ArgumentNotNull(passwordEncryptor, "passwordEncryptor"); Guard.InstanceNotNull(Password, "Password"); Salt = passwordEncryptor.GenerateSalt(); Password = Password.ComputePBKDF2Hash(Salt, passwordEncryptor); }