Пример #1
0
        public void TestExceptionInClickFilter()
        {
            // Create a substitute for all interface
            var display   = Substitute.For <IDisplay>();
            var extBitmap = Substitute.For <IExtBitmap>();
            var iLoad     = Substitute.For <ILoad>();
            var iSave     = Substitute.For <ISave>();
            // Get the instance of BusinessPresentation
            BusinessPresentation bp = new BusinessPresentation(iLoad, iSave, extBitmap, display);

            bp.FilteredBitmap = null;

            // Get a fake picture from the form
            PictureBox fakePictureBox = new PictureBox();

            fakePictureBox.Image = Properties.Resources.firefox;
            display.getImage(Arg.Any <PictureBox>()).Returns(fakePictureBox.Image);
            bp.setExtBitmap(extBitmap);

            // Throw exception
            extBitmap.Laplacian3x3Filter(Arg.Any <Bitmap>()).ReturnsForAnyArgs(x => { throw new Exception(); });

            try
            {
                // Apply the filter
                bp.ClickFilter(fakePictureBox);
            }
            catch (Exception)
            {
                Assert.Fail("The picture was note filtered");
            }

            // The filtered picture must be null
            Assert.IsNull(bp.FilteredBitmap);
        }
Пример #2
0
        public void TestClickFilterWithNullPictureBox()
        {
            // Create a substitute for all interface
            var display   = Substitute.For <IDisplay>();
            var extBitmap = Substitute.For <IExtBitmap>();
            var iLoad     = Substitute.For <ILoad>();
            var iSave     = Substitute.For <ISave>();
            // Get the instance of BusinessPresentation
            BusinessPresentation bp = new BusinessPresentation(iLoad, iSave, extBitmap, display);
            // Apply the filter with a null parameter
            string response = bp.ClickFilter(null);

            // Control the response
            Assert.AreEqual(response, "parameter picture box is null");
        }
Пример #3
0
        public void TestClickFilter()
        {
            // Create a substitute for all interface
            var display   = Substitute.For <IDisplay>();
            var extBitmap = Substitute.For <IExtBitmap>();
            var iLoad     = Substitute.For <ILoad>();
            var iSave     = Substitute.For <ISave>();

            // Get the instance of BusinessPresentation
            BusinessPresentation bp = new BusinessPresentation(iLoad, iSave, extBitmap, display);

            // Make a fake picture box with a fake picture
            PictureBox fakePictureBox = new PictureBox();

            fakePictureBox.Image = Properties.Resources.firefox;
            display.getImage(Arg.Any <PictureBox>()).Returns(fakePictureBox.Image);

            Assert.AreEqual("filter successfull applyied", bp.ClickFilter(fakePictureBox));
        }
Пример #4
0
        // Test of the ClickFilter with a null picture in the box (which is not null)
        public void TestClickFilterWithNullPicture()
        {
            // Create a substitute for all interface
            var display   = Substitute.For <IDisplay>();
            var extBitmap = Substitute.For <IExtBitmap>();
            var iLoad     = Substitute.For <ILoad>();
            var iSave     = Substitute.For <ISave>();
            // Get the instance of BusinessPresentation
            BusinessPresentation bp = new BusinessPresentation(iLoad, iSave, extBitmap, display);
            // Create a fake picture preview picture box, with a null picture
            PictureBox fakePictureBox = new PictureBox();

            fakePictureBox.Image = null;
            display.getImage(Arg.Any <PictureBox>()).Returns(fakePictureBox.Image);

            // Apply the filter
            string response = bp.ClickFilter(fakePictureBox);

            // Control the response
            Assert.AreEqual(response, "picture is null");
        }