Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }