public void PasswordPolicyException_ConstructorWithNull()
        {
            var passwordPolicyException = new PasswordPolicyException(null);

            Assert.IsNull(passwordPolicyException.Violations);
            Assert.IsTrue(string.IsNullOrEmpty(passwordPolicyException.ViolationsMessage));
        }
        public void PasswordPolicyException_ConstructorWithoutViolations()
        {
            var violations = new string[] { };
            var passwordPolicyException = new PasswordPolicyException(violations);

            Assert.AreEqual(((string[])(violations)).Length, ((string[])(passwordPolicyException.Violations)).Length);
            Assert.IsTrue(string.IsNullOrEmpty(passwordPolicyException.ViolationsMessage));
        }
        public void PasswordPolicyException_ConstructorWithViolations()
        {
            const string passwordCannotBeBlankViolation = "Passwords cannot be blank.";
            const string passwordIsUsernameViolation    = "Passwords cannot be the same as the username.";
            var          violations = new string[] { passwordCannotBeBlankViolation, passwordIsUsernameViolation };
            var          passwordPolicyException = new PasswordPolicyException(violations);

            Assert.AreEqual(((string[])(violations)).Length, ((string[])(passwordPolicyException.Violations)).Length);
            Assert.IsTrue(!string.IsNullOrEmpty(passwordPolicyException.ViolationsMessage));
        }
Example #4
0
        private bool PasswordMeetsPolicy(string Password, PWDTK.PasswordPolicy PassPolicy)
        {
            PasswordPolicyException pwdEx = new PasswordPolicyException("");

            if (PWDTK.TryPasswordPolicyCompliance(Password, PassPolicy, ref pwdEx))
            {
                return(true);
            }
            else
            {
                //Password does not comply with PasswordPolicy so we get the error message from the PasswordPolicyException to display to the user
                errorPasswd.SetError(txtPassword, pwdEx.Message);
                return(false);
            }
        }
Example #5
0
        private bool PasswordMeetsPolicy(String Password, PWDTK.PasswordPolicy PassPolicy)
        {
            PasswordPolicyException pwdEx = new PasswordPolicyException("");

            return(PWDTK.TryPasswordPolicyCompliance(Password, PassPolicy, ref pwdEx));
        }