}
[Test]
- [ExpectedException (typeof (FileNotFoundException))]
public void FileDoesNotExists ()
{
- Image.FromFile ("FileDoesNotExists.jpg");
+ Assert.Throws<FileNotFoundException> (() => Image.FromFile ("FileDoesNotExists.jpg"));
}
private bool CallbackTrue ()
}
[Test]
- [ExpectedException (typeof (OutOfMemoryException))]
public void GetThumbnailImage_Height_Zero ()
{
using (Bitmap bmp = new Bitmap (10, 10)) {
- Image tn = bmp.GetThumbnailImage (5, 0, new Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
+ Assert.Throws<OutOfMemoryException> (() => bmp.GetThumbnailImage (5, 0, new Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero));
}
}
[Test]
- [ExpectedException (typeof (OutOfMemoryException))]
public void GetThumbnailImage_Width_Negative ()
{
using (Bitmap bmp = new Bitmap (10, 10)) {
- Image tn = bmp.GetThumbnailImage (-5, 5, new Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
+ Assert.Throws<OutOfMemoryException> (() => bmp.GetThumbnailImage (-5, 5, new Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero));
}
}
[Test]
[Category ("NotWorking")] // https://bugzilla.novell.com/show_bug.cgi?id=338779
- [ExpectedException (typeof (ArgumentException))]
public void FromStream_Metafile_Wmf_NotOrigin ()
{
string filename = TestBitmap.getInFile ("bitmaps/telescope_01.wmf");
using (FileStream fs = File.OpenRead (filename)) {
fs.Position = fs.Length / 2;
- Image.FromStream (fs);
+ Assert.Throws<ArgumentException> (() => Image.FromStream (fs));
}
}
[Test]
[Category ("NotWorking")] // https://bugzilla.novell.com/show_bug.cgi?id=338779
- [ExpectedException (typeof (ArgumentException))]
public void FromStream_Metafile_Emf_NotOrigin ()
{
string filename = TestBitmap.getInFile ("bitmaps/milkmateya01.emf");
using (FileStream fs = File.OpenRead (filename)) {
fs.Position = fs.Length / 2;
- Image.FromStream (fs);
+ Assert.Throws<ArgumentException> (() => Image.FromStream (fs));
}
}
[Test]
- [ExpectedException (typeof (OutOfMemoryException))]
public void FromFile_Invalid ()
{
string filename = Assembly.GetExecutingAssembly ().Location;
- Image.FromFile (filename);
+ Assert.Throws<OutOfMemoryException> (() => Image.FromFile (filename));
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void FromStream_Invalid ()
{
string filename = Assembly.GetExecutingAssembly ().Location;
using (FileStream fs = File.OpenRead (filename)) {
- Image.FromStream (fs);
+ Assert.Throws<ArgumentException> (() => Image.FromStream (fs));
}
}
}
[Test]
- [ExpectedException (typeof (ArgumentException))]
public void StreamJunkSaveLoad ()
{
using (MemoryStream ms = new MemoryStream ()) {
bmp.Save (ms, ImageFormat.Bmp);
Assert.IsTrue (ms.Position > 2, "Position-2");
// exception here
- Image.FromStream (ms);
+ Assert.Throws<ArgumentException> (() => Image.FromStream (ms));
}
}
}