Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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());
        }
Пример #4
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);
        }
Пример #5
0
        public void IsValid_GivenPasswordAndPolicy_ReturnsExpectedValue(string policyPasswordCombo, bool expectedValue)
        {
            var sut = new sut.Password(policyPasswordCombo);

            Assert.Equal(expectedValue, sut.IsValid);
        }