Ejemplo n.º 1
0
        [TestMethod] // control the save and remove image methods (behaviour if non-existing)
        public void imageBad()
        {
            Boolean result;

            String[] files;
            Image    img;

            // save a corrupted image
            img    = null;
            result = _imageGood.save(img);
            Assert.AreEqual(false, result);

            // save in non-existing folder : return false and no image added
            img    = Image.FromFile(_path + "\\a.jpg");
            result = _imageBad.save(img);
            Assert.AreEqual(false, result);

            files = Directory.GetFiles(_goodFilename.getFolder());
            Assert.AreEqual(4, files.Length);

            // remove a non-existing image : return false, no image removed
            result = _imageBad.remove();
            Assert.AreEqual(false, result);

            files = Directory.GetFiles(_goodFilename.getFolder());
            Assert.AreEqual(4, files.Length);
        }
Ejemplo n.º 2
0
        public bool SaveImage(Image img, string picturename)
        {
            //give a unique name to image
            var dt      = DateTime.Now;
            var ticks   = dt.Ticks;
            var seconds = ticks / TimeSpan.TicksPerSecond;

            fm.setFileName(picturename + seconds);
            var saved = _im.save(img);

            return(saved);
        }
Ejemplo n.º 3
0
        [TestMethod] // control the save and remove image methods (behaviour if existing)
        public void imageGoodJpeg()
        {
            Boolean result;

            String[] files;

            // take an image to save and delete
            Image img = Image.FromFile(_path + "\\a.jpg");

            // save in good folder : return true and new image added
            result = _imageGood.save(img);
            Assert.AreEqual(true, result);

            files = Directory.GetFiles(_goodFilename.getFolder());
            Assert.AreEqual(5, files.Length); // 5, because originally there are 3 pictures + 1 text file

            // remove an existing image : return true and old image deleted
            result = _imageGood.remove();
            Assert.AreEqual(true, result);

            files = Directory.GetFiles(_goodFilename.getFolder());
            Assert.AreEqual(4, files.Length);
        }
        public UnitTest_ControlsManipulator()
        {
            _path = System.IO.Directory.GetCurrentDirectory() + "\\..\\..\\images";

            _imageGood = Substitute.For <IimageManipulation>();
            _imageGood.save(Arg.Any <Image>()).Returns(true);
            _imageGood.remove().Returns(true);

            _controlSubs = Substitute.For <IControlsManipulation>();
            _controlSubs.ApplyFilter(Arg.Any <string>(), Arg.Any <PictureBox>(), Arg.Any <TextBox>(), Arg.Any <Image>()).Returns(true);

            // instanciation for existing image
            _existingFilename = Substitute.For <IFilenameManipulation>();
            _existingFilename.getFolder().Returns(_path);
            _existingFilename.getFullPath().Returns(_path + "\\a.jpg");
            _existingFilename.getFileName().Returns("a");

            _imageExisting = new ImageManipulation(_existingFilename);
        }