public void CharacterFrequencyPasswordPolicyStringConstructor_ValidPolicy_ParsesAndSetsPropertiesCorrectly()
        {
            var sut = new sut.CharacterFrequencyPasswordPolicy("2-9 g");

            Assert.Equal('g', sut.RequiredCharacter);
            Assert.Equal(2, sut.LowerNumber);
            Assert.Equal(9, sut.UpperNumber);
        }
        public void CharacterFrequencyPasswordPolicyConstructor_ValidPolicy_SetsPropertiesCorrectly()
        {
            var sut = new sut.CharacterFrequencyPasswordPolicy('a', 10, 20);

            Assert.Equal('a', sut.RequiredCharacter);
            Assert.Equal(10, sut.LowerNumber);
            Assert.Equal(20, sut.UpperNumber);
        }
예제 #3
0
        public void PasswordGranularConstructor_GivenValidItems_SetsAppropriately()
        {
            var policy = new sut.CharacterFrequencyPasswordPolicy('a', 1, 2);
            var sut    = new sut.Password(policy, "a");

            Assert.Equal(policy, sut.PasswordPolicy);
            Assert.Equal("a", sut.PasswordCandidate);
        }
예제 #4
0
        public void PasswordMultiStringConstructor_GivenValidItems_SetsAppropriately()
        {
            var policyString = "5-9 b";
            var password     = "******";

            var sut    = new sut.Password(policyString, password);
            var policy = new sut.CharacterFrequencyPasswordPolicy(policyString);

            Assert.Equal(policy, sut.PasswordPolicy);
            Assert.Equal(password, sut.PasswordCandidate);
        }
예제 #5
0
        public void PasswordSingleStringConstructor_GivenValidString_SetsAppropriately()
        {
            var policyString      = "1-3 a";
            var passwordCandidate = "abcde";
            var policy            = new sut.CharacterFrequencyPasswordPolicy(policyString);

            var policyPasswordString = string.Format("{0}: {1}", policyString, passwordCandidate);

            var sut = new sut.Password(policyPasswordString);

            Assert.Equal(policy, sut.PasswordPolicy);
            Assert.Equal(passwordCandidate, sut.PasswordCandidate);
            Assert.Equal(policyPasswordString, sut.ToString());
        }
예제 #6
0
        public void PasswordMultiStringAndFactoryConstructor_GivenValidItems_SetsAppropriately()
        {
            var policyString = "5-9 b";
            var password     = "******";
            var factory      = new CharacterPositionPasswordPolicyFactory();

            var sut               = new sut.Password(policyString, password, factory);
            var policy            = new sut.CharacterPositionPasswordPolicy(policyString);
            var nonMatchingPolicy = new sut.CharacterFrequencyPasswordPolicy(policyString);

            Assert.Equal(policy, sut.PasswordPolicy);
            Assert.NotEqual(nonMatchingPolicy, sut.PasswordPolicy);
            Assert.Equal(password, sut.PasswordCandidate);
        }
        public void Validate_GivenInvalidPassword_ReturnsFalse(string passwordPolicyString, string password)
        {
            var sut = new sut.CharacterFrequencyPasswordPolicy(passwordPolicyString);

            Assert.False(sut.Validate(password));
        }