Ejemplo n.º 1
0
        // Description - Tests the functionality of cyclicCollage. Calls every
        //               overridden method except for replaceImage().
        //               replaceImage() is not intended to be used with
        //               cyclicCollage and will always return false when called.
        static void cyclicCollageTestSuite(imageCollage cyclicCollage)
        {
            Console.Write("Calling getDisplay() on cyclicCollage object 5 times: ");
            Console.WriteLine();
            repeatDisplay(cyclicCollage);
            Console.WriteLine();

            Console.Write("getDisplay() has been called ");
            Console.Write(cyclicCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            cyclicCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(cyclicCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            cyclicCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(cyclicCollage.getDisplay());
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        // Description - accepts a reference to an array of the base class imageCollage.
        //               randomly allocates 10 slots of collage objects followed by one
        //               of each object.
        static void allocateCollageArray(ref imageCollage[] colArray)
        {
            int collageSelector;
            int collageSize;

            for (int index = 0; index < colArray.Length; index++)
            {
                collageSelector = rnd.Next(NUM_COL);
                collageSize     = rnd.Next(MIN_IMG, MAX_IMG);
                if (index < RANDOM_SIZE) //Random portion of array
                {
                    if (collageSelector == IMAGE)
                    {
                        colArray[index] = new imageCollage(collageSize);
                    }
                    if (collageSelector == CYCLIC)
                    {
                        colArray[index] = new cyclicCollage(collageSize);
                    }
                    if (collageSelector == BIT)
                    {
                        colArray[index] = new bitCollage(collageSize);
                    }
                }
                if (index >= RANDOM_SIZE) // Constant portion of array used in test suites
                {
                    colArray[index] = new bitCollage(TEST_SIZE);
                    ++index;
                    colArray[index] = new cyclicCollage(TEST_SIZE);
                    ++index;
                    colArray[index] = new imageCollage(TEST_SIZE);
                }
            }
        }
Ejemplo n.º 3
0
 //Description - Helper method used in test suite methods
 static void repeatDisplay(imageCollage item, int rep = REPEAT)
 {
     for (int count = 0; count < rep; ++count)
     {
         displayCollage(item.getDisplay());
         Console.WriteLine();
     }
 }
Ejemplo n.º 4
0
        static void Main()
        {
            //**Page One***
            Console.Write("Creating a heterogeneous array to test the three collage classes... ");
            imageCollage[] heteroCollageArray = new imageCollage[H_ARRAY_SIZE];
            allocateCollageArray(ref heteroCollageArray);
            Console.Write("Done.");
            Console.WriteLine();
            Console.WriteLine();

            Console.Write("Displaying all collages in random portion of array: ");
            Console.WriteLine();
            displayAll(heteroCollageArray);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test imageCollage object...");
            Console.ReadKey(); //Input needed to continue

            //***Page Two***
            Console.Clear();
            Console.Write("Testing imageCollage functionality: ");
            Console.WriteLine();
            imageCollageTestSuite(heteroCollageArray[IMAGE_INDEX]);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test cyclicCollage object...");
            Console.ReadKey(); //Input
            
            //**Page Three***
            Console.Clear();
            Console.Write("Testing cyclicCollage functionality: ");
            Console.WriteLine();
            cyclicCollageTestSuite(heteroCollageArray[CYCLIC_INDEX]);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test bitCollage object...");
            Console.ReadKey(); //Input

            //***Page Four***
            Console.Clear();
            Console.Write("Testing bitCollage functionality: ");
            Console.WriteLine();
            bitCollageTestSuite(heteroCollageArray[BIT_INDEX]);
            Console.WriteLine();

            Console.Write("Press any key to exit...");
            Console.ReadKey(); //Input
        }
Ejemplo n.º 5
0
        static void Main()
        {
            //**Page One***
            Console.Write("Creating a heterogeneous array to test the three collage classes... ");
            imageCollage[] heteroCollageArray = new imageCollage[H_ARRAY_SIZE];
            allocateCollageArray(ref heteroCollageArray);
            Console.Write("Done.");
            Console.WriteLine();
            Console.WriteLine();

            Console.Write("Displaying all collages in random portion of array: ");
            Console.WriteLine();
            displayAll(heteroCollageArray);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test imageCollage object...");
            Console.ReadKey(); //Input needed to continue

            //***Page Two***
            Console.Clear();
            Console.Write("Testing imageCollage functionality: ");
            Console.WriteLine();
            imageCollageTestSuite(heteroCollageArray[IMAGE_INDEX]);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test cyclicCollage object...");
            Console.ReadKey(); //Input

            //**Page Three***
            Console.Clear();
            Console.Write("Testing cyclicCollage functionality: ");
            Console.WriteLine();
            cyclicCollageTestSuite(heteroCollageArray[CYCLIC_INDEX]);
            Console.WriteLine();
            Console.Write("Press any key to clear screen and test bitCollage object...");
            Console.ReadKey(); //Input

            //***Page Four***
            Console.Clear();
            Console.Write("Testing bitCollage functionality: ");
            Console.WriteLine();
            bitCollageTestSuite(heteroCollageArray[BIT_INDEX]);
            Console.WriteLine();

            Console.Write("Press any key to exit...");
            Console.ReadKey(); //Input
        }
Ejemplo n.º 6
0
        // This method initializes 1 imageCollage, 1 cyclicCollage, and 1 bitCollage and fills them with random sequnce sizes, subscriptions lengths and image ids.
        // As well as random parameters specific to the object type.
        public static imageCollage[] heteroCollage(int size)
        {
            imageCollage[] H = new imageCollage[size];

            int iQuantity = rand.Next(4, 11);

            H[0] = new imageCollage(iQuantity, rand.Next(5, 11));
            for (int n = 0; n < iQuantity; n++)
            {
                H[0].addImage(rand.Next(1000, 10000));
            }

            int cQuantity = rand.Next(4, 11);

            H[1] = new cyclicCollage(cQuantity, rand.Next(5, 11), 3);
            for (int n = 0; n < cQuantity; n++)
            {
                H[1].addImage(rand.Next(1000, 10000));
            }

            bool replaceable = false;
            int  x           = rand.Next(0, 1);

            if (x == 1)
            {
                replaceable = true;
            }
            int bQuantity = rand.Next(4, 11);

            H[2] = new bitCollage(bQuantity, rand.Next(5, 11), replaceable);
            for (int n = 0; n < bQuantity; n++)
            {
                H[2].addImage(rand.Next(1000, 10000));
            }
            return(H);
        }
Ejemplo n.º 7
0
 //Description - Used in main() to display the random portion of the hetero array
 static void displayAll(imageCollage[] collageArray)
 {
     for (int index = 0; index < collageArray.Length; index++)
     {
         if (index < RANDOM_SIZE)
         {
             Console.Write("Collage ");
             Console.Write(index + 1);
             Console.Write(": ");
             displayCollage(collageArray[index].getDisplay());
             Console.WriteLine();
         }
     }
 }
Ejemplo n.º 8
0
 //Description - Helper method used in test suite methods
 static void repeatDisplay(imageCollage item, int rep = REPEAT)
 {
     for (int count = 0; count < rep; ++count)
     {
         displayCollage(item.getDisplay());
         Console.WriteLine();
     }
 }
Ejemplo n.º 9
0
        // Description - Tests the functionality of bitCollage. Calls every
        //                overridden method.
        static void bitCollageTestSuite(imageCollage bitCollage)
        {
            Console.Write("Calling getDisplay() on bitCollage object 5 times: ");
            Console.WriteLine();
            repeatDisplay(bitCollage);
            Console.WriteLine();

            Console.Write("Testing replaceImage() bitCollage method: ");
            Console.WriteLine();
            Console.Write("Calling getDisplay() to fill an array of images to replace...");
            int[] replace = bitCollage.getDisplay();
            Console.Write("Done.");
            Console.WriteLine();
            foreach (int element in replace)
            {
                Console.Write("Attempting to replace ");
                Console.Write(element);
                Console.Write("...");
                if (bitCollage.replaceImage(element))
                    Console.Write("Success!");
                else
                    Console.Write("Failed!");
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Calling getDisplay() on bitCollage object 5 more times: ");
            Console.WriteLine();
            repeatDisplay(bitCollage);

            Console.WriteLine();
            Console.Write("getDisplay() has been called ");
            Console.Write(bitCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.Write(bitCollage.getReplaceCount());
            Console.Write(" images have been replaced.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            bitCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(bitCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            bitCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(bitCollage.getDisplay());
            Console.WriteLine();
        }
Ejemplo n.º 10
0
        // Description - Tests the functionality of cyclicCollage. Calls every
        //               overridden method except for replaceImage(). 
        //               replaceImage() is not intended to be used with
        //               cyclicCollage and will always return false when called.
        static void cyclicCollageTestSuite(imageCollage cyclicCollage)
        {
            Console.Write("Calling getDisplay() on cyclicCollage object 5 times: ");
            Console.WriteLine();
            repeatDisplay(cyclicCollage);
            Console.WriteLine();

            Console.Write("getDisplay() has been called ");
            Console.Write(cyclicCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            cyclicCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(cyclicCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            cyclicCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(cyclicCollage.getDisplay());
            Console.WriteLine();
        }
Ejemplo n.º 11
0
        // Description - Tests the functionality of imageCollage. Calls every method in
        //                in imageCollage under different conditions.
        static void imageCollageTestSuite(imageCollage imageCollage)
        {
            Console.Write("Calling getDisplay() on imageCollage object: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Testing replaceImage() imageCollage method: "); 
            Console.WriteLine();
            Console.Write("Calling getDisplay() to fill an array of images to replace...");
            int[] replace = imageCollage.getDisplay();
            Console.Write("Done.");
            Console.WriteLine();
            for (int index = 0; index < (TEST_SIZE / COLLAGE_PORTION); ++index)
            {
                Console.Write("Attempting to replace ");
                Console.Write(replace[index]);
                Console.Write("...");
                if (imageCollage.replaceImage(replace[index])) //Each call will succeed because
                    Console.Write("Success!");                 //   each ID is in the object
                else
                    Console.Write("Failed!");
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Calling getDisplay() on imageCollage object: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Testing imgQuery(): ");
            Console.WriteLine();
            Console.Write("Is ");
            Console.Write(replace[TEST_SIZE - 1]);
            Console.Write(" in the collage: ");
            if (imageCollage.imgQuery(replace[TEST_SIZE - 1]))
                Console.Write("Yes!");
            else
                Console.Write("No!");
            Console.WriteLine();
            Console.Write("Is ");
            Console.Write(replace[IMAGE]);
            Console.Write(" in the collage: ");
            if (imageCollage.imgQuery(replace[IMAGE]))
                Console.Write("Yes!");
            else
                Console.Write("No!");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("getDisplay() has been called ");
            Console.Write(imageCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.Write(imageCollage.getReplaceCount());
            Console.Write(" images have been replaced.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            imageCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to replace ");
            Console.Write(replace[TEST_SIZE - 1]); //This call will fail, already replaced above
            Console.Write("...");
            if (imageCollage.replaceImage(replace[TEST_SIZE - 1]))
                Console.Write("Success!");
            else
                Console.Write("Failed!");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            imageCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to replace ");
            Console.Write(replace[TEST_SIZE - 1]);
            Console.Write("...");
            if (imageCollage.replaceImage(replace[TEST_SIZE - 1]))
                Console.Write("Success!");
            else
                Console.Write("Failed!");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();


        }
Ejemplo n.º 12
0
        // Description - accepts a reference to an array of the base class imageCollage.
        //               randomly allocates 10 slots of collage objects followed by one
        //               of each object.
        static void allocateCollageArray(ref imageCollage[] colArray)
        {
            int collageSelector;
            int collageSize;

            for (int index = 0; index < colArray.Length; index++)
            {
                collageSelector = rnd.Next(NUM_COL);
                collageSize = rnd.Next(MIN_IMG, MAX_IMG);
                if (index < RANDOM_SIZE) //Random portion of array
                {
                    if (collageSelector == IMAGE)
                        colArray[index] = new imageCollage(collageSize);
                    if (collageSelector == CYCLIC)
                        colArray[index] = new cyclicCollage(collageSize);
                    if (collageSelector == BIT)
                        colArray[index] = new bitCollage(collageSize);
                }
                if (index >= RANDOM_SIZE) // Constant portion of array used in test suites
                {
                    colArray[index] = new bitCollage(TEST_SIZE);
                    ++index;
                    colArray[index] = new cyclicCollage(TEST_SIZE);
                    ++index;
                    colArray[index] = new imageCollage(TEST_SIZE);
                }
            }
        }
Ejemplo n.º 13
0
        // Description - Tests the functionality of bitCollage. Calls every
        //                overridden method.
        static void bitCollageTestSuite(imageCollage bitCollage)
        {
            Console.Write("Calling getDisplay() on bitCollage object 5 times: ");
            Console.WriteLine();
            repeatDisplay(bitCollage);
            Console.WriteLine();

            Console.Write("Testing replaceImage() bitCollage method: ");
            Console.WriteLine();
            Console.Write("Calling getDisplay() to fill an array of images to replace...");
            int[] replace = bitCollage.getDisplay();
            Console.Write("Done.");
            Console.WriteLine();
            foreach (int element in replace)
            {
                Console.Write("Attempting to replace ");
                Console.Write(element);
                Console.Write("...");
                if (bitCollage.replaceImage(element))
                {
                    Console.Write("Success!");
                }
                else
                {
                    Console.Write("Failed!");
                }
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Calling getDisplay() on bitCollage object 5 more times: ");
            Console.WriteLine();
            repeatDisplay(bitCollage);

            Console.WriteLine();
            Console.Write("getDisplay() has been called ");
            Console.Write(bitCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.Write(bitCollage.getReplaceCount());
            Console.Write(" images have been replaced.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            bitCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(bitCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            bitCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(bitCollage.getDisplay());
            Console.WriteLine();
        }
Ejemplo n.º 14
0
        // Description - Tests the functionality of imageCollage. Calls every method in
        //                in imageCollage under different conditions.
        static void imageCollageTestSuite(imageCollage imageCollage)
        {
            Console.Write("Calling getDisplay() on imageCollage object: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Testing replaceImage() imageCollage method: ");
            Console.WriteLine();
            Console.Write("Calling getDisplay() to fill an array of images to replace...");
            int[] replace = imageCollage.getDisplay();
            Console.Write("Done.");
            Console.WriteLine();
            for (int index = 0; index < (TEST_SIZE / COLLAGE_PORTION); ++index)
            {
                Console.Write("Attempting to replace ");
                Console.Write(replace[index]);
                Console.Write("...");
                if (imageCollage.replaceImage(replace[index])) //Each call will succeed because
                {
                    Console.Write("Success!");                 //   each ID is in the object
                }
                else
                {
                    Console.Write("Failed!");
                }
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.Write("Calling getDisplay() on imageCollage object: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Testing imgQuery(): ");
            Console.WriteLine();
            Console.Write("Is ");
            Console.Write(replace[TEST_SIZE - 1]);
            Console.Write(" in the collage: ");
            if (imageCollage.imgQuery(replace[TEST_SIZE - 1]))
            {
                Console.Write("Yes!");
            }
            else
            {
                Console.Write("No!");
            }
            Console.WriteLine();
            Console.Write("Is ");
            Console.Write(replace[IMAGE]);
            Console.Write(" in the collage: ");
            if (imageCollage.imgQuery(replace[IMAGE]))
            {
                Console.Write("Yes!");
            }
            else
            {
                Console.Write("No!");
            }
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("getDisplay() has been called ");
            Console.Write(imageCollage.getDisplayCount());
            Console.Write(" times.");
            Console.WriteLine();

            Console.Write(imageCollage.getReplaceCount());
            Console.Write(" images have been replaced.");
            Console.WriteLine();

            Console.WriteLine();
            Console.Write("Calling toggleActive()...");
            imageCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to replace ");
            Console.Write(replace[TEST_SIZE - 1]); //This call will fail, already replaced above
            Console.Write("...");
            if (imageCollage.replaceImage(replace[TEST_SIZE - 1]))
            {
                Console.Write("Success!");
            }
            else
            {
                Console.Write("Failed!");
            }
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();

            Console.Write("Calling toggleActive()...");
            imageCollage.toggleActive();
            Console.Write("Done.");
            Console.WriteLine();
            Console.Write("Attempting to replace ");
            Console.Write(replace[TEST_SIZE - 1]);
            Console.Write("...");
            if (imageCollage.replaceImage(replace[TEST_SIZE - 1]))
            {
                Console.Write("Success!");
            }
            else
            {
                Console.Write("Failed!");
            }
            Console.WriteLine();
            Console.Write("Attempting to display collage: ");
            Console.WriteLine();
            displayCollage(imageCollage.getDisplay());
            Console.WriteLine();
        }