Beispiel #1
0
        public void TestColorIfWidthNotDisibleBy4()
        {
            InterfaceFilter filterInterface = Substitute.For <ManagerFilter>();

            Bitmap originalBitmap = RetrieveImage.RetrieveOriginalPicture();

            //Create the bitmap that will be sent to the filter
            Bitmap testBitmap = new Bitmap(99, originalBitmap.Height);
            //Create the bitmap that will be colored with the supplement color
            Bitmap unifiedTestBitmapColor = new Bitmap(99, originalBitmap.Height);

            //Color the full picture with the default supplemant color for external pixels
            for (int i = 0; i < testBitmap.Width; i++)
            {
                for (int x = 0; x < testBitmap.Height; x++)
                {
                    unifiedTestBitmapColor.SetPixel(i, x, Color.FromArgb(testBitmap.GetPixel(i, x).R / 5, testBitmap.GetPixel(i, x).G / 5, testBitmap.GetPixel(i, x).B / 5));
                }
            }
            //send the testBitmap to the filter
            Bitmap receivedAfterTest = filterInterface.RainbowFilter(testBitmap);
            //Determine the pixel to compare
            int pixelToCheck = testBitmap.Width - 1;

            //Compare pixel
            Assert.AreEqual(unifiedTestBitmapColor.GetPixel(pixelToCheck, 1), receivedAfterTest.GetPixel(pixelToCheck, 1));
        }
Beispiel #2
0
        public void TestLoadImageFromComputer()
        {
            InterfaceInput inputInterface = Substitute.For <ManagerInputOutput>();

            Bitmap orginalBitmap = RetrieveImage.RetrieveOriginalPicture();
            Bitmap bitmapToLoadBeforeCopyToSquare = inputInterface.LoadImage();
            Bitmap bitmapToLoadAfterCopyToSquare  = inputInterface.CopyToSquareCanevas(bitmapToLoadBeforeCopyToSquare, 900);

            Assert.IsTrue(RetrieveImage.Equals(orginalBitmap, bitmapToLoadAfterCopyToSquare));
        }
Beispiel #3
0
        public void ConvolutionFilterTestOfExceptionWithMatrix()
        {
            //Substitute for ManagerEdge
            InterfaceEdge edgeInterface = Substitute.For <ManagerEdge>();
            //Getting the original image to be sent
            Bitmap originalBitmap = RetrieveImage.RetrieveOriginalPicture();
            //Bitmap bitmapForVerification retrieved using the ConvolutionFilter method with a matrix null
            Bitmap filteredBitmap = edgeInterface.ConvolutionFilter(originalBitmap, null, 1.0, 0);

            Assert.AreEqual(null, filteredBitmap);
        }
Beispiel #4
0
        public void Laplacian5x5FilterTestOutputPicture()
        {
            //Substitute for ManagerEdge
            InterfaceEdge edgeInterface = Substitute.For <ManagerEdge>();

            Bitmap originalBitmap        = RetrieveImage.RetrieveOriginalPicture();
            Bitmap bitmapForVerification = RetrieveImage.RetrieveImageFromPath("Laplacian5x5.jpg");
            Bitmap filteredBitmap        = edgeInterface.Lalpacian5x5(new Bitmap(originalBitmap));

            Assert.IsTrue(RetrieveImage.Equals(bitmapForVerification, filteredBitmap));
        }
Beispiel #5
0
        public void CrazyFilterTestOutputPicture()
        {
            //Substitute for the ManagerFilter
            InterfaceFilter filterInterface = Substitute.For <ManagerFilter>();

            Bitmap originalBitmap        = RetrieveImage.RetrieveOriginalPicture();
            Bitmap bitmapForVerification = RetrieveImage.RetrieveImageFromPath("Crazy.jpg");
            Bitmap filteredBitmap        = filterInterface.CrazyFilter(new Bitmap(originalBitmap));

            Assert.IsTrue(RetrieveImage.Equals(bitmapForVerification, filteredBitmap));
        }
Beispiel #6
0
        public void TestIfImageWidthIsSmallerThan4Pixels()
        {
            //Substitute for the ManagerFilter
            InterfaceFilter filterInterface = Substitute.For <ManagerFilter>();

            Bitmap originalBitmap = RetrieveImage.RetrieveOriginalPicture();

            Bitmap testBitmap        = new Bitmap(3, originalBitmap.Height);
            Bitmap receivedAfterTest = filterInterface.RainbowFilter(testBitmap);

            Assert.AreEqual(testBitmap, receivedAfterTest);
        }
Beispiel #7
0
        public void TestSaveImageToComputerFormatBMP()
        {
            //Substitute for ManagerInputOutput
            InterfaceOutput outputInterface = Substitute.For <ManagerInputOutput>();

            Bitmap originalBitmapToTest = RetrieveImage.RetrieveImageFromPath("egyptBMP.bmp");

            //Name the to be saved image "TestBPM.bmp"
            outputInterface.SaveImage(originalBitmapToTest);

            Bitmap savedBitmap = RetrieveImage.RetrieveImageFromPath("TestBMP.bmp");

            Assert.IsTrue(RetrieveImage.Equals(originalBitmapToTest, savedBitmap));
        }