[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); }
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); }
[TestMethod] // control the save and remove image methods (behaviour if existing) public void imageGoodPng() { 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 = _imageGoodPng.save(img); Assert.AreEqual(true, result); files = Directory.GetFiles(_goodFilenamePng.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 = _imageGoodPng.remove(); Assert.AreEqual(true, result); files = Directory.GetFiles(_goodFilenamePng.getFolder()); Assert.AreEqual(4, files.Length); }
public bool DeletePicture() { return(_im.remove()); }