Exemplo n.º 1
0
 public void setMementoTest()
 {
     Convolution target = new Convolution();
     int[,] expectedMatrix = new int[6, 6];
     Memento memento = new Memento("Conv", new int[6, 6]);
     target.setMemento(memento);
     Assert.IsTrue(target.matrix is int[,], "Memento.state is not a Matrix.");
     int[,] actualMatrix = (int[,])target.getMemento().state;
     for (int dim1 = 0; dim1 < expectedMatrix.GetLength(0); dim1++)
     {
         for (int dim2 = 0; dim2 < expectedMatrix.GetLength(1); dim2++)
         {
             Assert.AreEqual(expectedMatrix[dim1, dim2], actualMatrix[dim1, dim2], "Matrix is not expected matrix.");
         }
     }
 }
Exemplo n.º 2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            Convolution conv = new Convolution();
            testBitmap = new Bitmap(testPixel, testPixel);
            for (int height = 0; height < testBitmap.Height; height++)
            {
                for (int width = 0; width < testBitmap.Width; width++)
                {
                    testBitmap.SetPixel(width, height, Color.White);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Black);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Red);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Green);
                    width++;
                    testBitmap.SetPixel(width, height, Color.Blue);
                }
            }

            //create blur matrix
            int square = 3;
            matrix = new int[square, square];
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    matrix[i, j] = 1;
                }
            }
            blur = new Memento("Blur", matrix);
            //get blured Bitmap
            original = conv.getMemento();
            conv.setMemento(blur);
            processedBitmap = conv.process(testBitmap);
            conv.setMemento(original);
        }
Exemplo n.º 3
0
 public void getMementoTest_start()
 {
     Convolution target = new Convolution();
     Memento expected = original;
     Memento actual;
     actual = target.getMemento();
     int[,] matrixExpected = (int[,])expected.state;
     int[,] matrixActual = (int[,])actual.state;
     for (int i = 0; i < matrixExpected.GetLength(0); i++)
     {
         for (int j = 0; j < matrixExpected.GetLength(1); j++)
         {
             Assert.AreEqual(matrixExpected[i, j], matrixActual[i, j], "Memento object is not set to int[3, 3].");
         }
     }
     Assert.AreEqual(expected.name, actual.name, "Memento name is not PF_Convolution.");
 }