Exemplo n.º 1
0
            public void Should_parse_example_policies(
                string policyString,
                int expectedPos1,
                int expectedPos2,
                char expectedChar)
            {
                var policy = PasswordPolicy2.Parse(policyString);

                Assert.Equal(expectedPos1, policy.Pos1);
                Assert.Equal(expectedPos2, policy.Pos2);
                Assert.Equal(expectedChar, policy.Char);
            }
Exemplo n.º 2
0
            public void Puzzle_2B()
            {
                var inputs = PuzzleInputs.Puzzle2;

                var okPasswords = new ConcurrentBag <int>();

                Parallel.ForEach(inputs, input =>
                {
                    var parts  = input.Split(':');
                    var policy = PasswordPolicy2.Parse(parts[0]);
                    if (policy.Evaluate(parts[1].Trim()))
                    {
                        okPasswords.Add(1);
                    }
                });

                Assert.Equal(0, okPasswords.Sum());
            }
Exemplo n.º 3
0
            public void Should_evaluate_according_to_sample_data(
                int pos1,
                int pos2,
                char @char,
                string input,
                bool expected)
            {
                var policy = new PasswordPolicy2
                {
                    Pos1 = pos1,
                    Pos2 = pos2,
                    Char = @char
                };

                var result = policy.Evaluate(input);

                Assert.Equal(expected, result);
            }