Пример #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);
        }
Пример #2
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");
         }
     }
 }