Exemple #1
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);
        }
Exemple #2
0
 public void typeTest()
 {
     Convolution target = new Convolution();
     PluginType expected = PluginType.IFilterOqat;
     PluginType actual;
     target.type = expected;
     actual = target.type;
     Assert.AreEqual(expected, actual);
 }
Exemple #3
0
 public void propertyViewTest()
 {
     Convolution target = new Convolution();
     UserControl actual;
     actual = target.propertyView;
     Assert.IsNotNull(actual, "propertyView is not set.");
 }
Exemple #4
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.");
         }
     }
 }
Exemple #5
0
 public void processTest()
 {
     Convolution target = new Convolution();
     Bitmap frame = testBitmap;
     Bitmap expected = processedBitmap;
     Bitmap actual;
     target.setMemento(blur);
     actual = target.process(frame);
     for (int height = 0; height < expected.Height; height++)
     {
         for (int width = 0; width < expected.Width; width++)
         {
             Assert.AreEqual(expected.GetPixel(height, width), actual.GetPixel(height, width), "Process is working randomly");
         }
     }
 }
Exemple #6
0
 public void namePluginTest()
 {
     Convolution target = new Convolution();
     string expected = "Convolution";
     string actual;
     target.namePlugin = expected;
     actual = target.namePlugin;
     Assert.AreEqual(expected, actual);
 }
Exemple #7
0
 public void matrixTest()
 {
     Convolution target = new Convolution();
     int[,] expected = new int[3, 3];
     int[,] actual;
     actual = target.matrix;
     //Check ever matrix entry
     for (int dim1 = 0; dim1 < expected.GetLength(0); dim1++)
     {
         for (int dim2 = 0; dim2 < expected.GetLength(1); dim2++)
         {
             Assert.AreEqual(expected[dim1, dim2], actual[dim1, dim2], "Matrix " + expected.ToString() + " is not expected matrix " + target.matrix.ToString() + ". ");
         }
     }
 }
Exemple #8
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.");
 }
Exemple #9
0
 public void ConvolutionConstructorTest()
 {
     Convolution target = new Convolution();
     Assert.IsTrue(target is Convolution, "The returned object is not a valid Convolution instance.");
 }