Beispiel #1
0
        static pwdCheck[] Initialize_pwd_check_object_array(Random rand)
        {
            Console.WriteLine(ASTERISK + " Initializing Heterogeneous Collection of Objects " + ASTERISK);
            Console.WriteLine();

            const int MAX_STATE_CHANGES = 10;

            pwdCheck[] initializer_array = new pwdCheck[TEST_OBJ_ARRAY_SIZE];
            uint       random_password_length;
            int        random_valid_ascii_index;
            uint       max_state_changes;

            for (uint i = 0; i < TEST_OBJ_ARRAY_SIZE; i++)
            {
                random_password_length   = (uint)rand.Next(0, RANDOM_PASSWORD_LENGTH);
                random_valid_ascii_index = rand.Next(0, POSSIBLE_ASCII.Length);
                max_state_changes        = (uint)rand.Next(0, MAX_STATE_CHANGES);
                if (i < TEST_OBJ_ARRAY_SIZE / 3)
                {
                    initializer_array[i] = new pwdCheck(random_password_length, POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("Object " + i + " is a pwdCheck object.");
                }
                else if ((TEST_OBJ_ARRAY_SIZE / 3) <= i && TEST_OBJ_ARRAY_SIZE - (TEST_OBJ_ARRAY_SIZE / 3) > i)
                {
                    initializer_array[i] = new excessC(random_password_length, POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("Object " + i + " is an excessC object.");
                }
                else
                {
                    initializer_array[i] = new compundC(max_state_changes, random_password_length,
                                                        POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("Object " + i + " is a compundC object.");
                }
                Console.WriteLine("Object " + i + " took in a password of length: " + random_password_length);
                Console.WriteLine("After construction, object " + i + " has a password length requirement of: " +
                                  initializer_array[i].Minimum_Password_Length);
                Console.WriteLine("Object " + i + " has a forbidden character: " + POSSIBLE_ASCII[random_valid_ascii_index]);
                Console.WriteLine();
            }
            return(initializer_array);
        }
Beispiel #2
0
        static void Test_Default_Constructor_Parameters(Random rand, pwdCheck[] pwd_check_object_array)
        {
            Console.WriteLine(ASTERISK + " Testing the cases when the client enters a value outside " + ASTERISK);
            Console.WriteLine(ASTERISK + " of 4-20 characters and the no argument constructor " + ASTERISK);
            Console.WriteLine();

            const uint TEST_DEF_CONSTR_AMOUNT  = 2;
            const int  MAX_STATE_TOGGLE_LENGTH = 15;

            uint random_password_length;
            int  random_valid_ascii_index;
            uint random_toggle_max_length;

            for (uint i = 0; i < TEST_DEF_CONSTR_AMOUNT; i++)
            {
                random_password_length   = (uint)rand.Next(MAX_PWD_LENGTH_REQUIRMENT, MAX_PWD_LENGTH_REQUIRMENT * 2);
                random_valid_ascii_index = rand.Next(0, POSSIBLE_ASCII.Length);
                random_toggle_max_length = (uint)rand.Next(MAX_STATE_TOGGLE_LENGTH, MAX_STATE_TOGGLE_LENGTH * 2);

                if (i == 0)
                {
                    pwd_check_object_array[i] = new pwdCheck(random_password_length, POSSIBLE_ASCII[random_valid_ascii_index]);

                    Console.WriteLine("For exceeding the bounds of 4-20 characters\nThe length of the password" +
                                      " entered into object " + i + " is: " + random_password_length);
                    Console.WriteLine("Forbidden character entered into object " + i + " is: " +
                                      POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("The minimum length of the password of object " + i + " after construction is: " +
                                      pwd_check_object_array[i].Minimum_Password_Length);
                    Console.WriteLine();
                }
                else
                {
                    pwd_check_object_array[0] = new pwdCheck();

                    Console.WriteLine("No parameters were entered into object " + 0 + " constructor and the minimum length set " +
                                      "by default is: " + pwd_check_object_array[0].Minimum_Password_Length);
                    Console.WriteLine("Forbidden character by default in object " + 0 + " is a space");
                    Console.WriteLine();
                }
            }



            for (uint i = 0; i < TEST_DEF_CONSTR_AMOUNT; i++)
            {
                random_password_length   = (uint)rand.Next(MAX_PWD_LENGTH_REQUIRMENT, MAX_PWD_LENGTH_REQUIRMENT * 2);
                random_valid_ascii_index = rand.Next(0, POSSIBLE_ASCII.Length);
                random_toggle_max_length = (uint)rand.Next(MAX_STATE_TOGGLE_LENGTH, MAX_STATE_TOGGLE_LENGTH * 2);

                if (i == 0)
                {
                    pwd_check_object_array[COMPUND_TEST_OBJ] = new compundC(random_toggle_max_length, random_password_length,
                                                                            POSSIBLE_ASCII[random_valid_ascii_index]);
                    compundC obj6 = (compundC)pwd_check_object_array[COMPUND_TEST_OBJ];
                    Console.WriteLine("For exceeding the bounds of 4-20 characters\nThe length of the password" +
                                      " entered into object " + COMPUND_TEST_OBJ + " is: " + random_password_length);
                    Console.WriteLine("Forbidden character entered into object " + COMPUND_TEST_OBJ + " is: " +
                                      POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("The object toggle amount entered is : " + random_toggle_max_length);
                    Console.WriteLine("The minimum length of the password of object " + COMPUND_TEST_OBJ + " after construction is: " +
                                      pwd_check_object_array[COMPUND_TEST_OBJ].Minimum_Password_Length);
                    Console.WriteLine("The amount the object can be toggled after construction is: " + obj6.State_Change_Limit);
                    Console.WriteLine();
                }
                else
                {
                    pwd_check_object_array[COMPUND_TEST_OBJ] = new compundC();
                    compundC obj6 = (compundC)pwd_check_object_array[COMPUND_TEST_OBJ];
                    Console.WriteLine("No parameters will be entered into compundC test object (obj # 3)");
                    Console.WriteLine("The minimum length of the password obj " + COMPUND_TEST_OBJ + " will accept is: " +
                                      pwd_check_object_array[COMPUND_TEST_OBJ].Minimum_Password_Length);
                    Console.WriteLine("Forbidden character by default in object " + COMPUND_TEST_OBJ + " is a space");
                    Console.WriteLine("The amount the object can be toggled after construction is: " + COMPUND_TEST_OBJ +
                                      " can have is: " + obj6.State_Change_Limit);
                    Console.WriteLine();
                }
            }
            for (uint i = 0; i < TEST_DEF_CONSTR_AMOUNT; i++)
            {
                random_password_length   = (uint)rand.Next(MAX_PWD_LENGTH_REQUIRMENT, MAX_PWD_LENGTH_REQUIRMENT * 2);
                random_valid_ascii_index = rand.Next(0, POSSIBLE_ASCII.Length);
                random_toggle_max_length = (uint)rand.Next(MAX_STATE_TOGGLE_LENGTH, MAX_STATE_TOGGLE_LENGTH * 2);

                if (i == 0)
                {
                    Console.WriteLine("For exceeding the bounds of 4-20 characters\nThe length of the password" +
                                      " entered into object " + EXCESSC_TEST_OBJ + " is: " + random_password_length);
                    Console.WriteLine("Forbidden character entered into object " + EXCESSC_TEST_OBJ + " by default is: " +
                                      POSSIBLE_ASCII[random_valid_ascii_index]);
                    Console.WriteLine("The minimum length of the password of object " + EXCESSC_TEST_OBJ +
                                      " after construction is: " + pwd_check_object_array[EXCESSC_TEST_OBJ].Minimum_Password_Length);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("No parameters will be entered into excessC test object (obj # 6)");
                    Console.WriteLine("The minimum length of the password obj " + EXCESSC_TEST_OBJ + " will accept by default is: " +
                                      pwd_check_object_array[EXCESSC_TEST_OBJ].Minimum_Password_Length);
                    Console.WriteLine("Forbidden character by default in object " + EXCESSC_TEST_OBJ + " is a space");
                    Console.WriteLine();
                }
            }


            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }