Пример #1
0
        public bool CheckPassword(string policy)
        {
            var parsesPasswordPolicy = new ParsesPasswordPolicy(policy);

            if (
                (parsesPasswordPolicy.GetCharacter().ToCharArray()[0] ==
                 parsesPasswordPolicy.GetPassword()[parsesPasswordPolicy.GetMinimum() - 1])
                &&
                (parsesPasswordPolicy.GetCharacter().ToCharArray()[0] ==
                 parsesPasswordPolicy.GetPassword()[parsesPasswordPolicy.GetMaximum() - 1])
                )
            {
                return(false);
            }

            if ((parsesPasswordPolicy.GetCharacter().ToCharArray()[0] ==
                 parsesPasswordPolicy.GetPassword()[parsesPasswordPolicy.GetMinimum() - 1]))
            {
                return(true);
            }
            if ((parsesPasswordPolicy.GetCharacter().ToCharArray()[0] ==
                 parsesPasswordPolicy.GetPassword()[parsesPasswordPolicy.GetMaximum() - 1]))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        public bool CheckPassword(string password)
        {
            var parsesPasswordPolicy = new ParsesPasswordPolicy(password);
            var charCount            = parsesPasswordPolicy
                                       .GetPassword()
                                       .Count(c => c == parsesPasswordPolicy.GetCharacter().ToCharArray()[0]);

            return(charCount >= parsesPasswordPolicy.GetMinimum() && charCount <= parsesPasswordPolicy.GetMaximum());
        }
Пример #3
0
        public void ParsesPasswordPolicy_GetsPassword()
        {
            var subject = new ParsesPasswordPolicy("1-3 a: abcde");

            subject.GetPassword().Should().Be("abcde");
        }
Пример #4
0
        public void ParsesPasswordPolicy_GetsMaximumCharactersFromPasswordString()
        {
            var subject = new ParsesPasswordPolicy("1-3 a: abcde");

            subject.GetMaximum().Should().Be(3);
        }