Ejemplo n.º 1
0
        static void Test_Flip_Pwd_Check_Obj(Random rand, FlipPwdCheck flipPwdCheck_object)
        {
            uint flip_digit = (uint)rand.Next(0, RANDOM_FLIP_DIGIT_MAX);

            Console.WriteLine("Encapsulated password flipped before character #: " + flip_digit);
            Console.WriteLine("Flipped password: "******"Checking if the flipped password passes the pwdCheck: " +
                              flipPwdCheck_object.Check_Flipped_Password(flip_digit));
            Console.WriteLine("P value is: " + flipPwdCheck_object.Minimum_Password_Length);
            Console.WriteLine("Length of encapsulated pwd is: " + flipPwdCheck_object.Password_Length);
            Console.WriteLine("Is this object active?: " + flipPwdCheck_object.isActive);
            Console.WriteLine();
            Console.WriteLine("Now I will force this object to change state and then test its chaged functionality");
            Console.WriteLine();
            Console.WriteLine(ASTERISK);
            Console.WriteLine("Checking flipped password " + flipPwdCheck_object.Minimum_Password_Length + " times...");
            Console.WriteLine();


            for (uint i = 0; i < flipPwdCheck_object.Minimum_Password_Length; i++)
            {
                flip_digit = (uint)rand.Next(0, RANDOM_FLIP_DIGIT_MAX);
                Console.WriteLine("Encapsulated password flipped before character #: " + flip_digit);
                Console.WriteLine("Flipped password: "******"Checking if the flipped password passes the pwdCheck: " +
                                  flipPwdCheck_object.Check_Flipped_Password(flip_digit));
                Console.WriteLine("Is this object active?: " + flipPwdCheck_object.isActive);
                Console.WriteLine();
            }
            Console.WriteLine(ASTERISK);
            Console.WriteLine("The object has changed state. Testing its new functionality...");
            Console.WriteLine(ASTERISK);
            Console.WriteLine();


            flip_digit = (uint)rand.Next(0, RANDOM_FLIP_DIGIT_MAX);
            Console.WriteLine("Encapsulated password flipped before character #: " + flip_digit);
            Console.WriteLine("Flipped password: "******"Checking if the flipped password passes the pwdCheck: " +
                              flipPwdCheck_object.Check_Flipped_Password(flip_digit));
            Console.WriteLine("P value is: " + flipPwdCheck_object.Minimum_Password_Length);
            Console.WriteLine("Length of encapsulated pwd is: " + flipPwdCheck_object.Password_Length);
            Console.WriteLine("Is this object active?: " + flipPwdCheck_object.isActive);
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        static Flip[] Initialize_Flip_Object_Array(Random rand, pwdCheck[] pwd_check_object_array, string[] password_array)
        {
            Console.WriteLine("Creating heterogeneous collection of Flip and FlipPwdCheck objects for testing...");
            Console.WriteLine();

            Flip[] initializer_array = new Flip[TEST_OBJ_ARRAY_SIZE];
            int    pwd_index;
            int    pwd_obj_array_index;

            for (uint i = 0; i < TEST_OBJ_ARRAY_SIZE; i++)
            {
                pwd_index = rand.Next(0, (int)SIZE_OF_PASSWORD_FILE);

                if (i < TEST_OBJ_ARRAY_SIZE / 2)
                {
                    Console.WriteLine("Object " + i + " encapsulated password is: " + password_array[pwd_index]);
                    initializer_array[i] = new Flip(password_array[pwd_index]);
                }
                else
                {
                    Console.WriteLine("Object " + i + " encapsulated password is: " + password_array[pwd_index]);
                    pwd_obj_array_index  = rand.Next(0, (int)TEST_OBJ_ARRAY_SIZE);
                    initializer_array[i] = new FlipPwdCheck(password_array[pwd_index], pwd_check_object_array[pwd_obj_array_index]);
                    if (pwd_check_object_array[pwd_obj_array_index] is compundC)
                    {
                        Console.WriteLine("Object type entered into the Flip object is of type: copmundC");
                    }
                    else if (pwd_check_object_array[pwd_obj_array_index] is excessC)
                    {
                        Console.WriteLine("Object type entered into the Flip object is of type: excessC");
                    }
                    else
                    {
                        Console.WriteLine("Object type entered into the Flip object is of type: pwdCheck");
                    }
                }
            }
            Console.WriteLine();
            Console.WriteLine(ASTERISK);
            Console.WriteLine("Press enter to continue program...");
            Console.WriteLine(ASTERISK);
            Console.ReadLine();
            return(initializer_array);
        }