public bool OpenImage(IFilenameManipulation fm) { try { //open selected image and load it into picture boxes _im = new ImageManipulation(fm); var image = _im.openImage(); Form1._Form1.PopulatePictureBoxes(image, fm.getFileName()); image.Dispose(); return(true); } catch { return(false); } }
[TestMethod] // control the open image method public void openImage() { Image img; // open an existing image img = _imageExisting.openImage(); Assert.AreNotEqual(null, img); // open a non-existing image from a non-existing folder img = _imageBad.openImage(); Assert.AreEqual(null, img); // open a non-existing image from an existing folder img = _imageGood.openImage(); Assert.AreEqual(null, img); // open a corrupted image from an existing folder img = _imageBadExisting.openImage(); Assert.AreEqual(null, img); }