public void WrongSha512PasswordsWontBeUpgraded()
 {
     Action<string, string> updateHook = (username, password) =>
     {
         Assert.Fail("Wrong sha512 password must not be upgraded.");
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword("1" + DefaultAdminPassword, DefaultAdminUserName, DefaultAdminHash);
     Assert.IsFalse(isCorrect);
 }
 public void CorrectSha512PasswordsWontBeUpgraded()
 {
     Action<string, string> updateHook = (username, password) =>
     {
         Assert.Fail("Sha512 password does not need to be upgraded.");
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword(DefaultAdminPassword, DefaultAdminUserName, DefaultAdminHash);
     Assert.IsTrue(isCorrect);
 }
 public void CorrectMd5PasswordsWillBeUpgraded()
 {
     int correctUpgradeHookCalls = 0;
     var username = DefaultAdminUserName;
     var password = DefaultAdminPassword;
     Action<string, string> updateHook = (updateUsername, updatePassword) =>
     {
         Assert.AreEqual(username, updateUsername);
         Assert.AreEqual(password, updatePassword);
         ++correctUpgradeHookCalls;
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword(password, username, Md5DefaultAdminHash);
     Assert.IsTrue(isCorrect);
     Assert.AreEqual(1, correctUpgradeHookCalls, "Correct md5 password should be upgraded exactly once.");
 }