Make System.Drawing unit tests use Assert.Throws instead of [ExpectedException] ...
authorFrederik Carlier <frederik.carlier@quamotion.mobi>
Mon, 6 Mar 2017 17:12:35 +0000 (18:12 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 6 Mar 2017 17:12:35 +0000 (18:12 +0100)
* Use Assert.Throws<> intstead of ExpectedException

* System.Drawing.Tests: Use Assert.Throws instead of ExpectedException

36 files changed:
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathIteratorTest.cs
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/LinearGradientBrushTest.cs
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/PathGradientBrushTest.cs
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestColorBlend.cs
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs
mcs/class/System.Drawing/Test/System.Drawing.Imaging/MetafileTest.cs
mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs
mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
mcs/class/System.Drawing/Test/System.Drawing.Text/PrivateFontCollectionCas.cs
mcs/class/System.Drawing/Test/System.Drawing.Text/PrivateFontCollectionTest.cs
mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/ColorTranslator.cs
mcs/class/System.Drawing/Test/System.Drawing/FontFamilyTest.cs
mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
mcs/class/System.Drawing/Test/System.Drawing/PenTest.cs
mcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs
mcs/class/System.Drawing/Test/System.Drawing/SolidBrushTest.cs
mcs/class/System.Drawing/Test/System.Drawing/SystemFontsTest.cs
mcs/class/System.Drawing/Test/System.Drawing/SystemIconsTest.cs
mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs
mcs/class/System.Drawing/Test/System.Drawing/TestBrushes.cs
mcs/class/System.Drawing/Test/System.Drawing/TestColor.cs
mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
mcs/class/System.Drawing/Test/System.Drawing/TestFontConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs
mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestSizeFConverter.cs
mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs
mcs/class/System.Drawing/Test/System.Drawing/TextureBrushTest.cs

index a8ee4551a930133dbe9290c1fd78669c7c1fe149..876202f39fde38676e8e8288940074094d45abde 100644 (file)
@@ -73,7 +73,6 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void CopyData_NullPoints ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -81,13 +80,12 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = null;
                                        byte [] types = new byte [1];
-                                       Assert.AreEqual (0, gpi.CopyData (ref points, ref types, 0, 1));
+                                       Assert.Throws<NullReferenceException> (() => gpi.CopyData (ref points, ref types, 0, 1));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void CopyData_NullTypes ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -95,13 +93,12 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = new PointF [1];
                                        byte [] types = null;
-                                       Assert.AreEqual (0, gpi.CopyData (ref points, ref types, 0, 1));
+                                       Assert.Throws<NullReferenceException> (() =>gpi.CopyData (ref points, ref types, 0, 1));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void CopyData_DifferentSize ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -109,13 +106,12 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = new PointF [1];
                                        byte [] types = new byte [2];
-                                       Assert.AreEqual (0, gpi.CopyData (ref points, ref types, 0, 1));
+                                       Assert.Throws<ArgumentException> (() => gpi.CopyData (ref points, ref types, 0, 1));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Enumerate_NullPoints ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -123,13 +119,12 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = null;
                                        byte [] types = new byte [2];
-                                       Assert.AreEqual (0, gpi.Enumerate (ref points, ref types));
+                                       Assert.Throws<NullReferenceException> (() => gpi.Enumerate (ref points, ref types));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Enumerate_NullTypes ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -137,13 +132,12 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = new PointF [1];
                                        byte [] types = null;
-                                       Assert.AreEqual (0, gpi.Enumerate (ref points, ref types));
+                                       Assert.Throws<NullReferenceException> (() => gpi.Enumerate (ref points, ref types));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Enumerate_DifferentSize ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
@@ -151,7 +145,7 @@ namespace MonoTests.System.Drawing.Drawing2D {
                                using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
                                        PointF [] points = new PointF [1];
                                        byte [] types = new byte [2];
-                                       Assert.AreEqual (0, gpi.Enumerate (ref points, ref types));
+                                       Assert.Throws<ArgumentException> (() => gpi.Enumerate (ref points, ref types));
                                }
                        }
                }
index 1d44f318763de5d215b9aaed666c3b779e3f5df9..9674c311abbd4f19156908c4fa3b2d4bc7427100 100644 (file)
@@ -59,45 +59,39 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Point_Null_Byte ()
                {
-                       new GraphicsPath ((Point[]) null, new byte[1]);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ((Point[]) null, new byte[1]));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Constructor_Point_Byte_Null ()
                {
-                       new GraphicsPath (new Point[1], null);
+                       Assert.Throws<NullReferenceException> (() => new GraphicsPath (new Point[1], null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Point_Byte_LengthMismatch ()
                {
-                       new GraphicsPath (new Point[1], new byte [2]);
+                       Assert.Throws<ArgumentException> (() => new GraphicsPath (new Point[1], new byte [2]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_PointF_Null_Byte ()
                {
-                       new GraphicsPath ((PointF[])null, new byte [1]);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ((PointF[])null, new byte [1]));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Constructor_PointF_Byte_Null ()
                {
-                       new GraphicsPath ( new PointF[1], null);
+                       Assert.Throws<NullReferenceException> (() => new GraphicsPath ( new PointF[1], null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_PointF_Byte_LengthMismatch ()
                {
-                       new GraphicsPath (new PointF[2], new byte [1]);
+                       Assert.Throws<ArgumentException> (() => new GraphicsPath (new PointF[2], new byte [1]));
                }
 
                [Test]
@@ -116,17 +110,15 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void GraphicsPath_Empty_PathPoints ()
                {
-                       Assert.IsNull (new GraphicsPath ().PathPoints);
+                       Assert.Throws<ArgumentException> (() => Assert.IsNull (new GraphicsPath ().PathPoints));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void GraphicsPath_Empty_PathTypes ()
                {
-                       Assert.IsNull (new GraphicsPath ().PathTypes);
+                       Assert.Throws<ArgumentException> (() => Assert.IsNull (new GraphicsPath ().PathTypes));
                }
 
                [Test]
@@ -172,14 +164,13 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void FillMode_Invalid ()
                {
                        // constructor accept an invalid FillMode
                        GraphicsPath gp = new GraphicsPath ((FillMode) Int32.MaxValue);
                        Assert.AreEqual (Int32.MaxValue, (int) gp.FillMode, "MaxValue");
                        // but you can't set the FillMode property to an invalid value ;-)
-                       gp.FillMode = (FillMode) Int32.MaxValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => gp.FillMode = (FillMode) Int32.MaxValue);
                }
 
                [Test]
@@ -388,18 +379,16 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddBeziers_Point_Null ()
                {
-                       new GraphicsPath ().AddBeziers ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddBeziers ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddBeziers_3_Points ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddBeziers (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
+                       Assert.Throws<ArgumentException> (() => gp.AddBeziers (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) }));
                }
 
                [Test]
@@ -411,18 +400,16 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddBeziers_PointF_Null ()
                {
-                       new GraphicsPath ().AddBeziers ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddBeziers ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddBeziers_3_PointFs ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddBeziers (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddBeziers (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) }));
                }
 
                [Test]
@@ -641,19 +628,16 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddLines_Point_Null ()
                {
-                       new GraphicsPath ().AddLines ((Point[])null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddLines ((Point[])null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddLines_Point_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddLines (new Point[0]);
-                       CheckLine (gp);
+                       Assert.Throws<ArgumentException> (() => gp.AddLines (new Point[0]));
                }
 
                [Test]
@@ -675,19 +659,16 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddLines_PointF_Null ()
                {
-                       new GraphicsPath ().AddLines ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddLines ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddLines_PointF_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddLines (new PointF[0]);
-                       CheckLine (gp);
+                       Assert.Throws<ArgumentException> (() => gp.AddLines (new PointF[0]));
                }
 
                [Test]
@@ -846,33 +827,29 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddPolygon_Point_Null ()
                {
-                       new GraphicsPath ().AddPolygon ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddPolygon ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_Point_Empty ()
                {
-                       new GraphicsPath ().AddPolygon (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => new GraphicsPath ().AddPolygon (new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_Point_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddPolygon (new Point[1] { new Point (1, 1) });
+                       Assert.Throws<ArgumentException> (() => gp.AddPolygon (new Point[1] { new Point (1, 1) }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_Point_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddPolygon (new Point[2] { new Point (1, 1), new Point (2, 2) });
+                       Assert.Throws<ArgumentException> (() => gp.AddPolygon (new Point[2] { new Point (1, 1), new Point (2, 2) }));
                }
 
                [Test]
@@ -884,33 +861,29 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddPolygon_PointF_Null ()
                {
-                       new GraphicsPath ().AddPolygon ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddPolygon ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_PointF_Empty ()
                {
-                       new GraphicsPath ().AddPolygon (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => new GraphicsPath ().AddPolygon (new PointF[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_PointF_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddPolygon (new PointF[1] { new PointF (1f, 1f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddPolygon (new PointF[1] { new PointF (1f, 1f) }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddPolygon_PointF_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddPolygon (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddPolygon (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }));
                }
 
                [Test]
@@ -1084,20 +1057,17 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddRectangles_Int_Null ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddRectangles ((Rectangle[]) null);
+                       Assert.Throws<ArgumentNullException> (() => gp.AddRectangles ((Rectangle[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddRectangles_Int_Empty ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddRectangles (new Rectangle[0]);
-                       CheckRectangle (gp, 4);
+                       Assert.Throws<ArgumentException> (() => gp.AddRectangles (new Rectangle[0]));
                }
 
                [Test]
@@ -1109,20 +1079,17 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddRectangles_Float_Null ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddRectangles ((RectangleF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => gp.AddRectangles ((RectangleF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddRectangles_Float_Empty ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddRectangles ( new RectangleF[0]);
-                       CheckRectangle (gp, 4);
+                       Assert.Throws<ArgumentException> (() => gp.AddRectangles ( new RectangleF[0]));
                }
 
                [Test]
@@ -1163,10 +1130,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddPath_Null ()
                {
-                       new GraphicsPath ().AddPath (null, false);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddPath (null, false));
                }
 
                [Test]
@@ -1199,34 +1165,30 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddClosedCurve_Point_Null ()
                {
-                       new GraphicsPath ().AddClosedCurve ((Point[])null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddClosedCurve ((Point[])null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_Point_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new Point [0]);
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new Point [0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_Point_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new Point[1] { new Point (1, 1) });
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new Point[1] { new Point (1, 1) }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_Point_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new Point[2] { new Point (1, 1), new Point (2, 2) }));
                }
 
                [Test]
@@ -1238,34 +1200,30 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddClosedCurve_PointF_Null ()
                {
-                       new GraphicsPath ().AddClosedCurve ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddClosedCurve ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_PointF_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new PointF[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_PointF_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new PointF[1] { new PointF (1f, 1f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new PointF[1] { new PointF (1f, 1f) }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddClosedCurve_PointF_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddClosedCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddClosedCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }));
                }
 
                [Test]
@@ -1332,26 +1290,23 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddCurve_Point_Null ()
                {
-                       new GraphicsPath ().AddCurve ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddCurve ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_Point_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_Point_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new Point[1] { new Point (1, 1) });
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new Point[1] { new Point (1, 1) }));
                }
 
                [Test]
@@ -1375,35 +1330,31 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve3_Point_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) }, 0, 2, 0.5f);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) }, 0, 2, 0.5f));
                        // adding only two points isn't supported by GdipAddCurve3I
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddCurve_PointF_Null ()
                {
-                       new GraphicsPath ().AddCurve ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().AddCurve ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_PointF_0 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_PointF_1 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[1] { new PointF (1f, 1f) });
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[1] { new PointF (1f, 1f) }));
                }
 
                [Test]
@@ -1427,11 +1378,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve3_PointF_2 ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 2, 0.5f);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 2, 0.5f));
                        // adding only two points isn't supported by GdipAddCurve3
                }
 
@@ -1445,27 +1395,24 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_ZeroSegments ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 0, 0.5f);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 0, 0.5f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_NegativeSegments ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, -1, 0.5f);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, -1, 0.5f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddCurve_OffsetTooLarge ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 1, 2, 0.5f);
+                       Assert.Throws<ArgumentException> (() => gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 1, 2, 0.5f));
                }
 
                [Test]
@@ -1572,12 +1519,11 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void AddString_NullString ()
                {
                        GraphicsPath gp = new GraphicsPath ();
                        FontFamily ff = GetFontFamily ();
-                       gp.AddString (null, ff, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
+                       Assert.Throws<NullReferenceException> (() => gp.AddString (null, ff, 0, 10, new Point (10, 10), StringFormat.GenericDefault));
                }
 
                [Test]
@@ -1590,11 +1536,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddString_NullFontFamily ()
                {
                        GraphicsPath gp = new GraphicsPath ();
-                       gp.AddString ("mono", null, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
+                       Assert.Throws<ArgumentException> (() => gp.AddString ("mono", null, 0, 10, new Point (10, 10), StringFormat.GenericDefault));
                }
 
                [Test]
@@ -1779,10 +1724,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       new GraphicsPath ().Transform (null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().Transform (null));
                }
                [Test]
                public void Transform_Empty ()
@@ -1976,17 +1920,15 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Warp_Null ()
                {
-                       new GraphicsPath ().Warp (null, new RectangleF ());
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().Warp (null, new RectangleF ()));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Warp_NoPoints ()
                {
-                       new GraphicsPath ().Warp (new PointF[0], new RectangleF ());
+                       Assert.Throws<ArgumentException> (() => new GraphicsPath ().Warp (new PointF[0], new RectangleF ()));
                }
 
                [Test]
@@ -2461,10 +2403,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Widen_Pen_Null ()
                {
-                       new GraphicsPath ().Widen (null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().Widen (null));
                }
 
                [Test]
@@ -2520,10 +2461,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Widen_Pen_Null_Matrix ()
                {
-                       new GraphicsPath ().Widen (null, new Matrix ());
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().Widen (null, new Matrix ()));
                }
 
                [Test]
@@ -2538,14 +2478,13 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Widen_SinglePoint ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
                                gp.AddLines (new Point[1] { new Point (1, 1) });
                                // Special case - a line with a single point is valid
                                Assert.AreEqual (1, gp.PointCount, "PointCount");
-                               gp.Widen (Pens.Red);
+                               Assert.Throws<OutOfMemoryException> (() => gp.Widen (Pens.Red));
                                // oops ;-)
                        }
                }
@@ -2669,31 +2608,27 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsOutlineVisible_IntNull ()
                {
-                       new GraphicsPath ().IsOutlineVisible (1, 1, null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().IsOutlineVisible (1, 1, null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsOutlineVisible_FloatNull ()
                {
-                       new GraphicsPath ().IsOutlineVisible (1.0f, 1.0f, null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().IsOutlineVisible (1.0f, 1.0f, null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsOutlineVisible_PointNull ()
                {
-                       new GraphicsPath ().IsOutlineVisible (new Point (), null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().IsOutlineVisible (new Point (), null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsOutlineVisible_PointFNull ()
                {
-                       new GraphicsPath ().IsOutlineVisible (new PointF (), null);
+                       Assert.Throws<ArgumentNullException> (() => new GraphicsPath ().IsOutlineVisible (new PointF (), null));
                }
 
                private void IsOutlineVisible_Line (Graphics graphics)
index bb97b81288c7fb4ecd3a95d24a5255f6d26502e3..937c9ebbc792cae616e995b0e53c62cfb8248d3d 100644 (file)
@@ -325,33 +325,29 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void InterpolationColors_Colors_InvalidBlend ()
                {
                        // default Blend doesn't allow getting this property
-                       Assert.IsNotNull (default_brush.InterpolationColors.Colors);
+                       Assert.Throws<ArgumentException> (() => { var x = default_brush.InterpolationColors.Colors; });
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void InterpolationColors_Positions_InvalidBlend ()
                {
                        // default Blend doesn't allow getting this property
-                       Assert.IsNotNull (default_brush.InterpolationColors.Positions);
+                       Assert.Throws<ArgumentException> (() => { var x = default_brush.InterpolationColors.Positions; });
                }
 
                [Test]
-               [ExpectedException (typeof (IndexOutOfRangeException))]
                public void LinearColors_Empty ()
                {
-                       default_brush.LinearColors = new Color[0];
+                       Assert.Throws<IndexOutOfRangeException> (() => default_brush.LinearColors = new Color[0]);
                }
 
                [Test]
-               [ExpectedException (typeof (IndexOutOfRangeException))]
                public void LinearColors_One ()
                {
-                       default_brush.LinearColors = new Color[1];
+                       Assert.Throws<IndexOutOfRangeException> (() => default_brush.LinearColors = new Color[1]);
                }
 
                [Test]
@@ -400,10 +396,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       default_brush.Transform = null;
+                       Assert.Throws<ArgumentNullException> (() => default_brush.Transform = null);
                }
 
                [Test]
@@ -415,10 +410,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Transform_NonInvertible ()
                {
-                       default_brush.Transform = new Matrix (123, 24, 82, 16, 47, 30);
+                       Assert.Throws<ArgumentException> (() => default_brush.Transform = new Matrix (123, 24, 82, 16, 47, 30));
                }
 
                [Test]
@@ -436,17 +430,15 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void WrapMode_Clamp ()
                {
-                       default_brush.WrapMode = WrapMode.Clamp;
+                       Assert.Throws<ArgumentException> (() => default_brush.WrapMode = WrapMode.Clamp);
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void WrapMode_Invalid ()
                {
-                       default_brush.WrapMode = (WrapMode) Int32.MinValue;
+                       Assert.Throws<InvalidEnumArgumentException> (() => default_brush.WrapMode = (WrapMode) Int32.MinValue);
                }
 
 
@@ -466,17 +458,15 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform1_Null ()
                {
-                       default_brush.MultiplyTransform (null);
+                       Assert.Throws<ArgumentNullException> (() => default_brush.MultiplyTransform (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform2_Null ()
                {
-                       default_brush.MultiplyTransform (null, MatrixOrder.Append);
+                       Assert.Throws<ArgumentNullException> (() => default_brush.MultiplyTransform (null, MatrixOrder.Append));
                }
 
                [Test]
@@ -486,11 +476,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MultiplyTransform_NonInvertible ()
                {
                        Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30);
-                       default_brush.MultiplyTransform (noninvertible);
+                       Assert.Throws<ArgumentException> (() => default_brush.MultiplyTransform (noninvertible));
                }
 
                [Test]
@@ -550,11 +539,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void RotateTransform_InvalidOrder ()
                {
                        LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
-                       lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => lgb.RotateTransform (720, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -603,11 +591,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_InvalidOrder ()
                {
                        LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
-                       lgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => lgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -643,31 +630,27 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_FocusTooSmall ()
                {
-                       default_brush.SetBlendTriangularShape (-1);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (-1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_FocusTooBig ()
                {
-                       default_brush.SetBlendTriangularShape (1.01f);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1.01f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_ScaleTooSmall ()
                {
-                       default_brush.SetBlendTriangularShape (1, -1);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1, -1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_ScaleTooBig ()
                {
-                       default_brush.SetBlendTriangularShape (1, 1.01f);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetBlendTriangularShape (1, 1.01f));
                }
 
                [Test]
@@ -703,31 +686,27 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_FocusTooSmall ()
                {
-                       default_brush.SetSigmaBellShape (-1);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (-1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_FocusTooBig ()
                {
-                       default_brush.SetSigmaBellShape (1.01f);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1.01f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_ScaleTooSmall ()
                {
-                       default_brush.SetSigmaBellShape (1, -1);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1, -1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_ScaleTooBig ()
                {
-                       default_brush.SetSigmaBellShape (1, 1.01f);
+                       Assert.Throws<ArgumentException> (() => default_brush.SetSigmaBellShape (1, 1.01f));
                }
 
                [Test]
@@ -755,11 +734,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TranslateTransform_InvalidOrder ()
                {
                        LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
-                       lgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => lgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -875,42 +853,37 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void LinearColors_Null ()
                {
-                       default_brush.LinearColors = null;
+                       Assert.Throws<NullReferenceException> (() => default_brush.LinearColors = null);
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void InterpolationColors_Null ()
                {
-                       default_brush.InterpolationColors = null;
+                       Assert.Throws<ArgumentException> (() => default_brush.InterpolationColors = null);
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Blend_Null ()
                {
-                       default_brush.Blend = null;
+                       Assert.Throws<NullReferenceException> (() => default_brush.Blend = null);
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ZeroWidthRectangle ()
                {
                        Rectangle r = new Rectangle (10, 10, 0, 10);
                        Assert.AreEqual (0, r.Width, "Width");
-                       new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical);
+                       Assert.Throws<ArgumentException> (() => new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ZeroHeightRectangleF ()
                {
                        RectangleF r = new RectangleF (10.0f, 10.0f, 10.0f, 0.0f);
                        Assert.AreEqual (0.0f, r.Height, "Height");
-                       new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical);
+                       Assert.Throws<ArgumentException> (() => new LinearGradientBrush (r, Color.Red, Color.Blue, LinearGradientMode.Vertical));
                }
        }
 }
index bc7cd5d368f449758047fa1ed67aa06549d85f60..509fe22d5efb1b1ee853bd33144e74ca58d526f6 100644 (file)
@@ -91,30 +91,27 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new PathGradientBrush (gp);
+                       Assert.Throws<ArgumentNullException> (() => new PathGradientBrush (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_GraphicsPath_Empty ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
-                               new PathGradientBrush (gp);
+                               Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (gp));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_GraphicsPath_SinglePoint ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
                                gp.AddLines (new Point[1] { new Point (1, 1) });
                                // Special case - a line with a single point is valid
-                               new PathGradientBrush (gp);
+                               Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (gp));
                        }
                }
 
@@ -131,27 +128,24 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Point_Null ()
                {
                        Point[] pts = null;
-                       new PathGradientBrush (pts);
+                       Assert.Throws<ArgumentNullException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_Point_Empty ()
                {
                        Point[] pts = new Point [0];
-                       new PathGradientBrush (pts);
+                       Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_Point_One ()
                {
                        Point[] pts = new Point[1] { new Point (1, 1) };
-                       new PathGradientBrush (pts);
+                       Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
@@ -209,27 +203,24 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_PointF_Null ()
                {
                        PointF[] pts = null;
-                       new PathGradientBrush (pts);
+                       Assert.Throws<ArgumentNullException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_PointF_Empty ()
                {
                        PointF[] pts = new PointF[0];
-                       new PathGradientBrush (pts);
+                       Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void Constructor_PointF_One ()
                {
                        PointF[] pts = new PointF[1] { new PointF (1, 1) };
-                       new PathGradientBrush (pts);
+                       Assert.Throws<OutOfMemoryException> (() => new PathGradientBrush (pts));
                }
 
                [Test]
@@ -242,10 +233,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void Constructor_PointF_WrapMode_Invalid ()
                {
-                       PathGradientBrush pgb = new PathGradientBrush (pts_2f, (WrapMode)Int32.MinValue);
+                       Assert.Throws<InvalidEnumArgumentException> (() => new PathGradientBrush (pts_2f, (WrapMode)Int32.MinValue));
                }
 
                [Test]
@@ -398,11 +388,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SurroundColors_Empty ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.TileFlipXY)) {
-                               pgb.SurroundColors = new Color[0];
+                               Assert.Throws<ArgumentException> (() => pgb.SurroundColors = new Color[0]);
                        }
                }
 
@@ -448,10 +437,9 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       new PathGradientBrush (pts_2f, WrapMode.Clamp).Transform = null;
+                       Assert.Throws<ArgumentNullException> (() => new PathGradientBrush (pts_2f, WrapMode.Clamp).Transform = null);
                }
 
                [Test]
@@ -464,11 +452,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Transform_NonInvertible ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.Transform = new Matrix (123, 24, 82, 16, 47, 30);
+                               Assert.Throws<ArgumentException> (() => pgb.Transform = new Matrix (123, 24, 82, 16, 47, 30));
                        }
                }
 
@@ -484,11 +471,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void WrapMode_Invalid ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.WrapMode = (WrapMode) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => pgb.WrapMode = (WrapMode) Int32.MinValue);
                        }
                }
 
@@ -507,20 +493,18 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform1_Null ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.MultiplyTransform (null);
+                               Assert.Throws<ArgumentNullException> (() => pgb.MultiplyTransform (null));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform2_Null ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.MultiplyTransform (null, MatrixOrder.Append);
+                               Assert.Throws<ArgumentNullException> (() => pgb.MultiplyTransform (null, MatrixOrder.Append));
                        }
                }
 
@@ -533,12 +517,11 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MultiplyTransform_NonInvertible ()
                {
                        using (Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30)) {
                                using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                                       pgb.MultiplyTransform (noninvertible);
+                                       Assert.Throws<ArgumentException> (() => pgb.MultiplyTransform (noninvertible));
                                }
                        }
                }
@@ -607,11 +590,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void RotateTransform_InvalidOrder ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.RotateTransform (720, (MatrixOrder) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => pgb.RotateTransform (720, (MatrixOrder) Int32.MinValue));
                        }
                }
 
@@ -649,11 +631,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_InvalidOrder ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => pgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue));
                        }
                }
 
@@ -692,38 +673,34 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_FocusTooSmall ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetBlendTriangularShape (-1);
+                               Assert.Throws<ArgumentException> (() => pgb.SetBlendTriangularShape (-1));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_FocusTooBig ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetBlendTriangularShape (1.01f);
+                               Assert.Throws<ArgumentException> (() => pgb.SetBlendTriangularShape (1.01f));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_ScaleTooSmall ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetBlendTriangularShape (1, -1);
+                               Assert.Throws<ArgumentException> (() => pgb.SetBlendTriangularShape (1, -1));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetBlendTriangularShape_ScaleTooBig ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetBlendTriangularShape (1, 1.01f);
+                               Assert.Throws<ArgumentException> (() => pgb.SetBlendTriangularShape (1, 1.01f));
                        }
                }
 
@@ -762,38 +739,34 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_FocusTooSmall ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetSigmaBellShape (-1);
+                               Assert.Throws<ArgumentException> (() => pgb.SetSigmaBellShape (-1));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_FocusTooBig ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetSigmaBellShape (1.01f);
+                               Assert.Throws<ArgumentException> (() => pgb.SetSigmaBellShape (1.01f));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_ScaleTooSmall ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetSigmaBellShape (1, -1);
+                               Assert.Throws<ArgumentException> (() => pgb.SetSigmaBellShape (1, -1));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetSigmaBellShape_ScaleTooBig ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.SetSigmaBellShape (1, 1.01f);
+                               Assert.Throws<ArgumentException> (() => pgb.SetSigmaBellShape (1, 1.01f));
                        }
                }
 
@@ -823,11 +796,10 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TranslateTransform_InvalidOrder ()
                {
                        using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
-                               pgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => pgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue));
                        }
                }
 
@@ -877,37 +849,34 @@ namespace MonoTests.System.Drawing.Drawing2D {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Blend_Null ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
                                gp.AddLines (pts_2f);
                                using (PathGradientBrush pgb = new PathGradientBrush (gp)) {
-                                       pgb.Blend = null;
+                                       Assert.Throws<NullReferenceException> (() => pgb.Blend = null);
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void InterpolationColors_Null ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
                                gp.AddLines (pts_2f);
                                using (PathGradientBrush pgb = new PathGradientBrush (gp)) {
-                                       pgb.InterpolationColors = null;
+                                       Assert.Throws<NullReferenceException> (() => pgb.InterpolationColors = null);
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void SurroundColors_Null ()
                {
                        using (GraphicsPath gp = new GraphicsPath ()) {
                                gp.AddLines (pts_2f);
                                using (PathGradientBrush pgb = new PathGradientBrush (gp)) {
-                                       pgb.SurroundColors = null;
+                                       Assert.Throws<NullReferenceException> (() => pgb.SurroundColors = null);
                                }
                        }
                }
index ffe43baaf86bdf10cd476cccb24a0b04745e53b2..79c3bdc55074b5a50396207dd55a1dfeb4c24941 100644 (file)
@@ -96,10 +96,9 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
                public void ColorBlend_Negative ()
                {
-                       ColorBlend cb = new ColorBlend (-1);
+                       Assert.Throws<OverflowException> (() => new ColorBlend (-1));
                }
 
                [Test]
index 4907c5b21e0126e9e201735f50c179e3c8a33c59..e95e81be01d005867f414a16a6cef12601d92be9 100644 (file)
@@ -83,24 +83,21 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Int_Null ()
                {
-                       new Matrix (rect, null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix (rect, null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Int_Empty ()
                {
-                       new Matrix (rect, new Point[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix (rect, new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Int_4Point ()
                {
-                       new Matrix (rect, new Point[4]);
+                       Assert.Throws<ArgumentException> (() => new Matrix (rect, new Point[4]));
                }
 
                [Test]
@@ -118,24 +115,21 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Float_Null ()
                {
-                       new Matrix (rectf, null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix (rectf, null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Float_Empty ()
                {
-                       new Matrix (rectf, new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix (rectf, new PointF[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Float_2PointF ()
                {
-                       new Matrix (rectf, new PointF[2]);
+                       Assert.Throws<ArgumentException> (() => new Matrix (rectf, new PointF[2]));
                }
 
                [Test]
@@ -332,10 +326,9 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Rotate_InvalidOrder ()
                {
-                       new Matrix ().Rotate (180, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().Rotate (180, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -353,17 +346,15 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void RotateAt_InvalidOrder ()
                {
-                       new Matrix ().RotateAt (180, new PointF (10, 10), (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().RotateAt (180, new PointF (10, 10), (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Multiply_Null ()
                {
-                       new Matrix (10, 20, 30, 40, 50, 60).Multiply (null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix (10, 20, 30, 40, 50, 60).Multiply (null));
                }
 
                [Test]
@@ -381,10 +372,9 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Multiply_Null_Order ()
                {
-                       new Matrix (10, 20, 30, 40, 50, 60).Multiply (null, MatrixOrder.Append);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix (10, 20, 30, 40, 50, 60).Multiply (null, MatrixOrder.Append));
                }
 
                [Test]
@@ -416,11 +406,10 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Multiply_InvalidOrder ()
                {
                        Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
-                       matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60), (MatrixOrder)Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60), (MatrixOrder)Int32.MinValue));
                }
 
                [Test]
@@ -513,10 +502,9 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Scale_InvalidOrder ()
                {
-                       new Matrix ().Scale (2, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().Scale (2, 1, (MatrixOrder) Int32.MinValue));
                }
                
                [Test]
@@ -544,10 +532,9 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Shear_InvalidOrder ()
                {
-                       new Matrix ().Shear (-1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().Shear (-1, 1, (MatrixOrder) Int32.MinValue));
                }
                
                [Test]
@@ -571,31 +558,27 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void TransformPoints_Point_Null ()
                {
-                       new Matrix ().TransformPoints ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix ().TransformPoints ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void TransformPoints_PointF_Null ()
                {
-                       new Matrix ().TransformPoints ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix ().TransformPoints ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TransformPoints_Point_Empty ()
                {
-                       new Matrix ().TransformPoints (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().TransformPoints (new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TransformPoints_PointF_Empty ()
                {
-                       new Matrix ().TransformPoints (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().TransformPoints (new PointF[0]));
                }
                
                [Test]
@@ -619,31 +602,27 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void TransformVectors_Point_Null ()
                {
-                       new Matrix ().TransformVectors ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix ().TransformVectors ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void TransformVectors_PointF_Null ()
                {
-                       new Matrix ().TransformVectors ((PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix ().TransformVectors ((PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TransformVectors_Point_Empty ()
                {
-                       new Matrix ().TransformVectors (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().TransformVectors (new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TransformVectors_PointF_Empty ()
                {
-                       new Matrix ().TransformVectors (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().TransformVectors (new PointF[0]));
                }
 
                [Test]
@@ -661,24 +640,21 @@ namespace MonoTests.System.Drawing.Drawing2D
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Translate_InvalidOrder ()
                {
-                       new Matrix ().Translate (-1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().Translate (-1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void VectorTransformPoints_Null ()
                {
-                       new Matrix ().VectorTransformPoints ((Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => new Matrix ().VectorTransformPoints ((Point[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void VectorTransformPoints_Empty ()
                {
-                       new Matrix ().VectorTransformPoints (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => new Matrix ().VectorTransformPoints (new Point[0]));
                }
        }
 }
index 56e96bc789c822b944da0a4436cb715c3b6ae7f7..c89706d04770b1b674ed5b17d07b844f2efd71ba 100644 (file)
@@ -57,32 +57,28 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_Stream_Null ()
                {
-                       new Metafile ((Stream)null);
+                       Assert.Throws<ArgumentException> (() => new Metafile ((Stream)null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Metafile_String_Null ()
                {
-                       new Metafile ((string) null);
+                       Assert.Throws<ArgumentNullException> (() => new Metafile ((string) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_String_Empty ()
                {
-                       new Metafile (String.Empty);
+                       Assert.Throws<ArgumentException> (() => new Metafile (String.Empty));
                }
 
                [Test]
-               [ExpectedException (typeof (ExternalException))]
                public void Metafile_String_FileDoesNotExists ()
                {
                        string filename = getInFile ("telescope_02.wmf");
-                       new Metafile (filename);
+                       Assert.Throws<ExternalException> (() => new Metafile (filename));
                }
 
                [Test]
@@ -94,10 +90,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ExternalException))]
                public void GetMetafileHeader_Bitmap ()
                {
-                       new Metafile (getInFile (Bitmap));
+                       Assert.Throws<ExternalException> (() => new Metafile (getInFile (Bitmap)));
                }
 
                static public void Check_MetaHeader_WmfPlaceable (MetaHeader mh)
@@ -284,10 +279,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Static_GetMetafileHeader_Stream_Null ()
                {
-                       MetafileHeader header = Metafile.GetMetafileHeader ((Stream)null);
+                       Assert.Throws<NullReferenceException> (() => Metafile.GetMetafileHeader ((Stream)null));
                }
 
                [Test]
@@ -301,10 +295,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Static_GetMetafileHeader_Filename_Null ()
                {
-                       MetafileHeader header = Metafile.GetMetafileHeader ((string) null);
+                       Assert.Throws<ArgumentNullException> (() => Metafile.GetMetafileHeader ((string) null));
                }
 
                [Test]
@@ -332,14 +325,12 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Static_GetMetafileHeader_IntPtr_Zero ()
                {
-                       Metafile.GetMetafileHeader (IntPtr.Zero);
+                       Assert.Throws<ArgumentException> (() => Metafile.GetMetafileHeader (IntPtr.Zero));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Static_GetMetafileHeader_IntPtr ()
                {
                        string filename = MetafileTest.getInFile (MetafileTest.WmfPlaceable);
@@ -348,22 +339,20 @@ namespace MonoTests.System.Drawing.Imaging {
                                IntPtr hemf = mf.GetHenhmetafile ();
                                Assert.IsTrue (hemf != IntPtr.Zero, "GetHenhmetafile");
 
-                               Metafile.GetMetafileHeader (hemf);
+                               Assert.Throws<ArgumentException> (() => Metafile.GetMetafileHeader (hemf));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_IntPtrBool_Zero ()
                {
-                       new Metafile (IntPtr.Zero, false);
+                       Assert.Throws<ArgumentException> (() => new Metafile (IntPtr.Zero, false));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_IntPtrEmfType_Zero ()
                {
-                       new Metafile (IntPtr.Zero, EmfType.EmfOnly);
+                       Assert.Throws<ArgumentException> (() => new Metafile (IntPtr.Zero, EmfType.EmfOnly));
                }
 
                private void CheckEmptyHeader (Metafile mf, EmfType type)
@@ -407,10 +396,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_IntPtrEmfType_Invalid ()
                {
-                       Metafile_IntPtrEmfType ((EmfType)Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => Metafile_IntPtrEmfType ((EmfType)Int32.MinValue));
                }
 
                [Test]
@@ -432,10 +420,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_IntPtrRectangle_Zero ()
                {
-                       new Metafile (IntPtr.Zero, new Rectangle (1, 2, 3, 4));
+                       Assert.Throws<ArgumentException> (() => new Metafile (IntPtr.Zero, new Rectangle (1, 2, 3, 4)));
                }
 
                [Test]
@@ -456,10 +443,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_IntPtrRectangleF_Zero ()
                {
-                       new Metafile (IntPtr.Zero, new RectangleF (1, 2, 3, 4));
+                       Assert.Throws<ArgumentException> (() => new Metafile (IntPtr.Zero, new RectangleF (1, 2, 3, 4)));
                }
 
                [Test]
@@ -496,10 +482,9 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Metafile_StreamIntPtrEmfType_Null ()
                {
-                       Metafile_StreamEmfType (null, EmfType.EmfOnly);
+                       Assert.Throws<NullReferenceException> (() => Metafile_StreamEmfType (null, EmfType.EmfOnly));
                }
 
                [Test]
@@ -511,11 +496,10 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Metafile_StreamIntPtrEmfType_Invalid ()
                {
                        using (MemoryStream ms = new MemoryStream ()) {
-                               Metafile_StreamEmfType (ms, (EmfType)Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => Metafile_StreamEmfType (ms, (EmfType)Int32.MinValue));
                        }
                }
 
@@ -575,24 +559,21 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CreateFilename_MultipleGraphics_EmfOnly ()
                {
-                       CreateFilename (EmfType.EmfOnly, false);
+                       Assert.Throws<OutOfMemoryException> (() => CreateFilename (EmfType.EmfOnly, false));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CreateFilename_MultipleGraphics_EmfPlusDual ()
                {
-                       CreateFilename (EmfType.EmfPlusDual, false);
+                       Assert.Throws<OutOfMemoryException> (() => CreateFilename (EmfType.EmfPlusDual, false));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CreateFilename_MultipleGraphics_EmfPlusOnly ()
                {
-                       CreateFilename (EmfType.EmfPlusOnly, false);
+                       Assert.Throws<OutOfMemoryException> (() => CreateFilename (EmfType.EmfPlusOnly, false));
                }
 
                [Test]
index ecce1ac458bc1ea1ef0248445371d54137a6ca55..b80e8a548bf70d3797ab77192a61e493c5c4a970 100644 (file)
@@ -40,40 +40,36 @@ namespace MonoTests.System.Drawing.Imaging {
        public class ColorMatrixTest {\r
 \r
                [Test]\r
-               [ExpectedException (typeof (NullReferenceException))]\r
                public void Constructor_Null ()\r
                {\r
-                       new ColorMatrix (null);\r
+                       Assert.Throws<NullReferenceException> (() => new ColorMatrix (null));\r
                }\r
 \r
                [Test]\r
-               [ExpectedException (typeof (IndexOutOfRangeException))]\r
                public void Constructor_TooSmallArraySize ()\r
                {\r
-                       new ColorMatrix (new float[][] { });\r
+                       Assert.Throws<IndexOutOfRangeException> (() => new ColorMatrix (new float[][] { }));\r
                }\r
 \r
                [Test]\r
-               [ExpectedException (typeof (IndexOutOfRangeException))]\r
                public void Constructor_TooWideArraySize ()\r
                {\r
-                       new ColorMatrix (new float[][] {\r
+                       Assert.Throws<IndexOutOfRangeException> (() => new ColorMatrix (new float[][] {\r
                                new float[] { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f }\r
-                       });\r
+                       }));\r
                }\r
 \r
                [Test]\r
-               [ExpectedException (typeof (IndexOutOfRangeException))]\r
                public void Constructor_TooTallArraySize ()\r
                {\r
-                       new ColorMatrix (new float[][] {\r
+                       Assert.Throws<IndexOutOfRangeException> (() => new ColorMatrix (new float[][] {\r
                                new float[] { 0.0f },\r
                                new float[] { 1.0f },\r
                                new float[] { 2.0f },\r
                                new float[] { 3.0f },\r
                                new float[] { 4.0f },\r
                                new float[] { 5.0f }\r
-                       });\r
+                       }));\r
                }\r
 \r
                [Test]\r
@@ -116,7 +112,6 @@ namespace MonoTests.System.Drawing.Imaging {
                }\r
 \r
                [Test]\r
-               [ExpectedException (typeof (IndexOutOfRangeException))]\r
                public void TooBigItems ()\r
                {\r
                        ColorMatrix cm = new ColorMatrix (new float[][] {\r
@@ -127,7 +122,7 @@ namespace MonoTests.System.Drawing.Imaging {
                                new float[] { 4.0f, 4.1f, 4.2f, 4.3f, 4.4f, 4.5f },\r
                                new float[] { 5.0f, 5.1f, 5.2f, 5.3f, 5.4f, 5.5f }\r
                        });\r
-                       Assert.AreEqual (5.5f, cm[5,5], "out");\r
+                       Assert.Throws<IndexOutOfRangeException> (() => { var x = cm[5, 5]; });\r
                }\r
 \r
                [Test]\r
@@ -169,10 +164,10 @@ namespace MonoTests.System.Drawing.Imaging {
                {\r
                        ColorMatrix cm = new ColorMatrix (new float[][] {\r
                                new float[] {0.393f, 0.349f, 0.272f, 0, 0},\r
-                               new float[] {0.769f, 0.686f, 0.534f, 0, 0},\r
-                               new float[] {0.189f, 0.168f, 0.131f, 0, 0},\r
-                               new float[] {     0,      0,      0, 1, 0},\r
-                               new float[] {     0,      0,      0, 0, 1}\r
+                               new float[] {0.769f, 0.686f, 0.534f, 0, 0},\r
+                               new float[] {0.189f, 0.168f, 0.131f, 0, 0},\r
+                               new float[] {     0,      0,      0, 1, 0},\r
+                               new float[] {     0,      0,      0, 0, 1}\r
                        });\r
 \r
                        Assert.AreEqual (0.393f, cm.Matrix00, "00");\r
index b4724040e1e4b1908ca15fe12af82095708422a4..75860915c3cec463c961084bcb2dcb8c81b40cdf 100644 (file)
@@ -174,11 +174,10 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_Null ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (null);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (null));
                        }
                }
 
@@ -196,92 +195,82 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_Default_Any ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, ColorAdjustType.Any);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, ColorAdjustType.Any));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_Default_Count ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, ColorAdjustType.Count);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, ColorAdjustType.Count));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Any ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Any);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Any));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Bitmap ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Bitmap);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Bitmap));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Brush ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Brush);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Brush));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Count ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Count);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Count));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Default ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Default);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Default));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Pen ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Pen);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Pen));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_AltGrays_Text ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Text);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.AltGrays, ColorAdjustType.Text));
                        }
                }
 
@@ -299,47 +288,42 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_SkipGrays_Any ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.SkipGrays, ColorAdjustType.Any);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.SkipGrays, ColorAdjustType.Any));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_SkipGrays_Count ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.SkipGrays, ColorAdjustType.Count);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.SkipGrays, ColorAdjustType.Count));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_InvalidFlag ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, (ColorMatrixFlag) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, (ColorMatrixFlag) Int32.MinValue));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrix_InvalidType()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, (ColorAdjustType)Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrix (global_color_matrix, ColorMatrixFlag.Default, (ColorAdjustType)Int32.MinValue));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrices_Null_ColorMatrix ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrices (null, global_color_matrix);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrices (null, global_color_matrix));
                        }
                }
 
@@ -354,11 +338,10 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrices_ColorMatrix_Null_AltGrays ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrices (global_color_matrix, null, ColorMatrixFlag.AltGrays);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrices (global_color_matrix, null, ColorMatrixFlag.AltGrays));
                        }
                }
 
@@ -400,20 +383,18 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrices_InvalidFlags ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrices (global_color_matrix, global_color_matrix, (ColorMatrixFlag) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrices (global_color_matrix, global_color_matrix, (ColorMatrixFlag) Int32.MinValue));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetColorMatrices_InvalidType ()
                {
                        using (ImageAttributes ia = new ImageAttributes ()) {
-                               ia.SetColorMatrices (global_color_matrix, global_color_matrix, ColorMatrixFlag.Default, (ColorAdjustType) Int32.MinValue);
+                               Assert.Throws<ArgumentException> (() => ia.SetColorMatrices (global_color_matrix, global_color_matrix, ColorMatrixFlag.Default, (ColorAdjustType) Int32.MinValue));
                        }
                }
 
index 3c2b8b5bd0e8795c1713e84ab2b18195114aec9d..2687d712b7e64d6fb7e6f0ad7091236b42f8c11e 100644 (file)
@@ -52,31 +52,28 @@ namespace MonoCasTests.System.Drawing.Text {
                // TODO - tests for AddFontFile
 
                [Test]
-               [ExpectedException (typeof (SecurityException))]
                [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
                public void AddMemoryFont_Deny_UnmanagedCode () 
                {
-                       new PrivateFontCollection ().AddMemoryFont (IntPtr.Zero, 1024);
+                       Assert.Throws<SecurityException> (() => new PrivateFontCollection ().AddMemoryFont (IntPtr.Zero, 1024));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
                public void AddMemoryFont_PermitOnly_UnmanagedCode ()
                {
-                       new PrivateFontCollection ().AddMemoryFont (IntPtr.Zero, 1024);
+                       Assert.Throws<ArgumentException> (() => new PrivateFontCollection ().AddMemoryFont (IntPtr.Zero, 1024));
                }
 
                // yes, that fails with FileNotFoundException ;-)
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
                public void AddMemoryFont_NegativeLength ()
                {
                        IntPtr ptr = Marshal.AllocHGlobal (1024);
                        try {
-                               new PrivateFontCollection ().AddMemoryFont (ptr, -1024);
+                               Assert.Throws<FileNotFoundException> (() => new PrivateFontCollection ().AddMemoryFont (ptr, -1024));
                        }
                        finally {
                                Marshal.FreeHGlobal (ptr);
@@ -84,13 +81,12 @@ namespace MonoCasTests.System.Drawing.Text {
                }
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
                public void AddMemoryFont_InvalidData ()
                {
                        IntPtr ptr = Marshal.AllocHGlobal (1024);
                        try {
-                               new PrivateFontCollection ().AddMemoryFont (ptr, 1024);
+                               Assert.Throws<FileNotFoundException> (() => new PrivateFontCollection ().AddMemoryFont (ptr, 1024));
                        }
                        finally {
                                Marshal.FreeHGlobal (ptr);
index 4eed43bc81ba764ee7d0c04bade41df208c0bdfb..c0d131870207c473a471b02b583e91b91581af31 100644 (file)
@@ -49,40 +49,36 @@ namespace MonoTests.System.Drawing.Text {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void AddFontFile_Null ()
                {
-                       new PrivateFontCollection ().AddFontFile (null);
+                       Assert.Throws<ArgumentNullException> (() => new PrivateFontCollection ().AddFontFile (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void AddFontFile_Empty ()
                {
                        // badly formetted filename
-                       new PrivateFontCollection ().AddFontFile (String.Empty);
+                       Assert.Throws<ArgumentException> (() => new PrivateFontCollection ().AddFontFile (String.Empty));
                }
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                [Category ("NotWorking")] // it seems fontconfig doesn't validate on add...
                public void AddFontFile_NotAFontFile ()
                {
                        string file = Path.GetTempFileName ();
                        Assert.IsTrue (File.Exists (file), "Exists");
                        // even if the file exists....
-                       new PrivateFontCollection ().AddFontFile (file);
+                       Assert.Throws<FileNotFoundException> (() => new PrivateFontCollection ().AddFontFile (file));
                }
 
                // tests for AddMemoryFont are available in the CAS unit tests
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Family ()
                {
                        PrivateFontCollection pfc = new PrivateFontCollection ();
                        pfc.Dispose ();
-                       Assert.IsNotNull (pfc.Families);
+                       Assert.Throws<ArgumentException> (() => { var x = pfc.Families; });
                        // no it's not a ObjectDisposedException
                }
        }
index 34cb3aa190976e52807d0bea65890082a09f86ba..4877f496996b847baa5f131a26a54a155ff620d9 100644 (file)
@@ -167,72 +167,63 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFrom_x1 ()
                {
-                               colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "10, 20");
+                       Assert.Throws<ArgumentException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "10, 20"));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFrom_x2 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "-10, 20, 30");
+                       Assert.Throws<ArgumentException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "-10, 20, 30"));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFrom_x3 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                                       "1, 1, 1, 1, 1");
+                       Assert.Throws<ArgumentException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                                       "1, 1, 1, 1, 1"));
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void ConvertFrom_x4 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                               "*1, 1");
+                       Assert.Throws<Exception> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                               "*1, 1"));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_x5 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                                       new Point (10, 10));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                                       new Point (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_x6 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                                       new PointF (10, 10));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                                       new PointF (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_x7 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                                       new Size (10, 10));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                                       new Size (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_x8 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
-                                       new SizeF (10, 10));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                                       new SizeF (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_x9 ()
                {
-                       colconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10);
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10));
                }
 
                [Test]
@@ -264,43 +255,38 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_x1 ()
                {
-                       colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
-                                       typeof (Color));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+                                       typeof (Color)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_x2 ()
                {
-                       colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
-                                       typeof (SizeF));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+                                       typeof (SizeF)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_x3 ()
                {
-                       colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
-                                       typeof (Point));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+                                       typeof (Point)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_x4 ()
                {
-                       colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
-                                       typeof (PointF));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+                                       typeof (PointF)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_x5 ()
                {
-                       colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
-                                       typeof (int));
+                       Assert.Throws<NotSupportedException> (() => colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+                                       typeof (int)));
                }
 
                [Test]
@@ -351,10 +337,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromInvariantString_InvalidComponentCount ()
                {
-                       colconv.ConvertFromInvariantString ("1, 2, 3, 4, 5");
+                       Assert.Throws<ArgumentException> (() => colconv.ConvertFromInvariantString ("1, 2, 3, 4, 5"));
                }
 
                [Test]
@@ -378,12 +363,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromString_InvalidComponentCount ()
                {
                        CultureInfo culture = CultureInfo.CurrentCulture;
-                       colconv.ConvertFromString (string.Format (culture,
-                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator[0]));
+                       Assert.Throws<ArgumentException> (() => colconv.ConvertFromString (string.Format (culture,
+                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator[0])));
                }
 
                [Test]
@@ -428,10 +412,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void ConvertFromString_FromHtml_PoundTooLarge ()
                {
-                       colconv.ConvertFromString ("#100000000");
+                       Assert.Throws<Exception> (() => colconv.ConvertFromString ("#100000000"));
                }
        }
 }
index 27ee0f55305493680b0b4796047f2bdd5a171aaf..85401b1d04e5fd375ad04d4948ab9caf7e9f132d 100644 (file)
@@ -84,24 +84,21 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void FromHtml_PoundNegative ()
                {
-                       ColorTranslator.FromHtml ("#-1");
+                       Assert.Throws<Exception> (() => ColorTranslator.FromHtml ("#-1"));
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void FromHtml_PoundTooLarge ()
                {
-                       ColorTranslator.FromHtml ("#100000000");
+                       Assert.Throws<Exception> (() => ColorTranslator.FromHtml ("#100000000"));
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void FromHtml_Unknown ()
                {
-                       ColorTranslator.FromHtml ("unknown-color-test");
+                       Assert.Throws<Exception> (() => ColorTranslator.FromHtml ("unknown-color-test"));
                }
 
                [Test]
index 3de56a5215255346e75a780efcdc6a4dbd358123..69f6a44f4f94b9bfb998760bed047fabc7c3187a 100644 (file)
@@ -59,18 +59,16 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FontFamily_String_Null ()
                {
-                       new FontFamily (null);
+                       Assert.Throws<ArgumentException> (() => new FontFamily (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")] // libgdiplus/fontconfig always return something
                public void FontFamily_String_Empty ()
                {
-                       new FontFamily (String.Empty);
+                       Assert.Throws<ArgumentException> (() => new FontFamily (String.Empty));
                }
 
                private void CheckMono (FontFamily ff)
@@ -110,10 +108,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FontFamily_String_PrivateFontCollection ()
                {
-                       new FontFamily (name, new PrivateFontCollection ());
+                       Assert.Throws<ArgumentException> (() => new FontFamily (name, new PrivateFontCollection ()));
                }
 
                [Test]
@@ -179,10 +176,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void GetFamilies_Null ()
                {
-                       FontFamily.GetFamilies (null);
+                       Assert.Throws<ArgumentNullException> (() => FontFamily.GetFamilies (null));
                }
 
                [Test]
@@ -201,12 +197,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_UseAfter ()
                {
                        FontFamily ff = FontFamily.GenericMonospace;
                        ff.Dispose ();
-                       Assert.AreEqual (name, ff.Name, "Name");
+                       Assert.Throws<ArgumentException> (() => { var x = ff.Name; });
                }
        }
 }
index d81f63c593cedb2676fc8d93072f342eab0e1c25..958aa0bb31907f87a009abc73daa667031716b1e 100644 (file)
@@ -911,7 +911,6 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                public void GdipLoadImageFromFile_FileNotFound ()
                {
                        string filename = "filenotfound";
@@ -921,11 +920,10 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (IntPtr.Zero, image, "image handle");
 
                        // this doesn't throw a OutOfMemoryException
-                       Image.FromFile (filename);
+                       Assert.Throws<FileNotFoundException> (() => Image.FromFile (filename));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void GdipCreateBitmapFromFile_FileNotFound ()
                {
                        string filename = "filenotfound";
@@ -934,7 +932,7 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipCreateBitmapFromFile (filename, out bitmap), "GdipCreateBitmapFromFile");
                        Assert.AreEqual (IntPtr.Zero, bitmap, "bitmap handle");
 
-                       new Bitmap (filename);
+                       Assert.Throws<ArgumentException> (() => new Bitmap (filename));
                }
 
                [Test]
@@ -1182,8 +1180,8 @@ namespace MonoTests.System.Drawing {
                                         "DrawCurve with 1 pt");
                        Assert.AreEqual (Status.Ok,
                                         GDIPlus.GdipDrawCurveI (graphics, pen,
-                                                                new Point [] { new Point (1, 1),
-                                                                               new Point (2, 2) }, 2),
+                                                                new Point [] { new Point (1, 1),
+                                                                               new Point (2, 2) }, 2),
                                         "DrawCurve with 2 pts");
 
                        // DrawClosedCurve
@@ -1193,12 +1191,12 @@ namespace MonoTests.System.Drawing {
                                         "DrawClosedCurve with no pts");
                        Assert.AreEqual (Status.InvalidParameter,
                                         GDIPlus.GdipDrawClosedCurveI (graphics, pen,
-                                                                      new Point [] { new Point (1, 1) }, 1),
+                                                                      new Point [] { new Point (1, 1) }, 1),
                                         "DrawClosedCurve with 1 pt");
                        Assert.AreEqual (Status.InvalidParameter,
                                         GDIPlus.GdipDrawClosedCurveI (graphics, pen,
-                                                                      new Point [] { new Point (1, 1),
-                                                                                     new Point (2, 2) }, 2),
+                                                                      new Point [] { new Point (1, 1),
+                                                                                     new Point (2, 2) }, 2),
                                         "DrawClosedCurve with 2 pt2");
 
                        // DrawPolygon
@@ -1208,7 +1206,7 @@ namespace MonoTests.System.Drawing {
                                         "DrawPolygon with no pts");
                        Assert.AreEqual (Status.InvalidParameter,
                                         GDIPlus.GdipDrawPolygonI (graphics, pen,
-                                                                  new Point [] { new Point (1, 1) }, 1),
+                                                                  new Point [] { new Point (1, 1) }, 1),
                                         "DrawPolygon with only one pt");
 
                        GDIPlus.GdipDeletePen (pen);                    
@@ -1224,12 +1222,12 @@ namespace MonoTests.System.Drawing {
                                         "FillClosedCurve with no pts");
                        Assert.AreEqual (Status.Ok,
                                         GDIPlus.GdipFillClosedCurveI (graphics, brush, 
-                                                                      new Point [] { new Point (1, 1) }, 1),
+                                                                                               new Point [] { new Point (1, 1) }, 1),
                                         "FillClosedCurve with 1 pt");
                        Assert.AreEqual (Status.Ok,
                                         GDIPlus.GdipFillClosedCurveI (graphics, brush,
-                                                                      new Point [] { new Point (1, 1),
-                                                                                     new Point (2, 2) }, 2),
+                                                                      new Point [] { new Point (1, 1),
+                                                                                     new Point (2, 2) }, 2),
                                         "FillClosedCurve with 2 pts");
                        
                        GDIPlus.GdipDeleteBrush (brush);
index 8ceeb112c59a0415e99115d199e1f82274132f93..bc050f3daab24ba5ba19a1293c1d24e5e4a1922e 100644 (file)
@@ -122,10 +122,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Brush_Null ()
                {
-                       new Pen ((Brush) null);
+                       Assert.Throws<ArgumentNullException> (() => new Pen ((Brush) null));
                }
 
                [Test]
@@ -138,10 +137,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_Brush_Float_Null ()
                {
-                       new Pen ((Brush) null, Single.MaxValue);
+                       Assert.Throws<ArgumentNullException> (() => new Pen ((Brush) null, Single.MaxValue));
                }
 
                [Test]
@@ -212,10 +210,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void Alignment_Invalid ()
                {
-                       default_pen.Alignment = (PenAlignment) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.Alignment = (PenAlignment) Int32.MinValue);
                }
 
                [Test]
@@ -235,10 +232,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Brush_Null ()
                {
-                       default_pen.Brush = null;
+                       Assert.Throws<ArgumentNullException> (() => default_pen.Brush = null);
                }
 
                [Test]
@@ -253,11 +249,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")] // not supported by libgdiplus
                public void CustomEndCap_Default ()
                {
-                       CustomLineCap clc = default_pen.CustomEndCap;
+                       Assert.Throws<ArgumentException> (() => { var x = default_pen.CustomEndCap; });
                }
 
                [Test]
@@ -272,11 +267,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")] // not supported by libgdiplus
                public void CustomStartCap_Default ()
                {
-                       CustomLineCap clc = default_pen.CustomStartCap;
+                       Assert.Throws<ArgumentException> (() => { var x = default_pen.CustomStartCap; });
                }
 
                [Test]
@@ -293,10 +287,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void DashCap_Invalid ()
                {
-                       default_pen.DashCap = (DashCap) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.DashCap = (DashCap) Int32.MinValue);
                }
 
                [Test]
@@ -324,10 +317,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DashPattern_Empty ()
                {
-                       default_pen.DashPattern = new float[0];
+                       Assert.Throws<ArgumentException> (() => default_pen.DashPattern = new float[0]);
                }
 
                [Test]
@@ -342,10 +334,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void DashStyle_Invalid ()
                {
-                       default_pen.DashStyle = (DashStyle) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.DashStyle = (DashStyle) Int32.MinValue);
                }
 
                [Test]
@@ -428,11 +419,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                [Category ("NotWorking")] // MS bug reported as FDBK50053
                public void DashPattern_Default ()
                {
-                       float[] pattern = default_pen.DashPattern;
+                       Assert.Throws<OutOfMemoryException> (() => { var x = default_pen.DashPattern; });
                }
 
                [Test]
@@ -447,10 +437,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void EndCap_Invalid ()
                {
-                       default_pen.EndCap = (LineCap) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.EndCap = (LineCap) Int32.MinValue);
                }
 
                [Test]
@@ -465,10 +454,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void LineJoin_Invalid ()
                {
-                       default_pen.LineJoin = (LineJoin) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.LineJoin = (LineJoin) Int32.MinValue);
                }
 
                [Test]
@@ -496,25 +484,22 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
                public void StartCap_Invalid ()
                {
-                       default_pen.StartCap = (LineCap) Int32.MinValue;
+                       Assert.Throws<SC.InvalidEnumArgumentException> (() => default_pen.StartCap = (LineCap) Int32.MinValue);
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       default_pen.Transform = null;
+                       Assert.Throws<ArgumentNullException> (() => default_pen.Transform = null);
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Transform_NonInvertible ()
                {
                        using (Pen p = new Pen (Brushes.Snow, Single.MaxValue)) {
-                               p.Transform = new Matrix (123, 24, 82, 16, 47, 30);
+                               Assert.Throws<ArgumentException> (() => p.Transform = new Matrix (123, 24, 82, 16, 47, 30));
                        }
                }
 
@@ -541,12 +526,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose ()
                {
                        Pen p = new Pen (Brushes.Red);
                        p.Dispose ();
-                       p.Alignment = PenAlignment.Center;
+                       Assert.Throws<ArgumentException> (() => p.Alignment = PenAlignment.Center);
                        // exception but not an ObjectDisposedException
                }
 
@@ -606,18 +590,16 @@ namespace MonoTests.System.Drawing {
 
                [Test]
                //[ExpectedException (typeof (ArgumentNullException))] // reported as FDBK50058
-               [ExpectedException (typeof (NullReferenceException))]
                public void MultiplyTransform1_Null ()
                {
-                       default_pen.MultiplyTransform (null);
+                       Assert.Throws<NullReferenceException> (() => default_pen.MultiplyTransform (null));
                }
 
                [Test]
                //[ExpectedException (typeof (ArgumentNullException))] // reported as FDBK50058
-               [ExpectedException (typeof (NullReferenceException))]
                public void MultiplyTransform2_Null ()
                {
-                       default_pen.MultiplyTransform (null, MatrixOrder.Append);
+                       Assert.Throws<NullReferenceException> (() => default_pen.MultiplyTransform (null, MatrixOrder.Append));
                }
 
                [Test]
@@ -643,12 +625,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MultiplyTransform_NonInvertible ()
                {
                        using (Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30)) {
                                using (Pen p = new Pen (Brushes.Red)) {
-                                       p.MultiplyTransform (noninvertible);
+                                       Assert.Throws<ArgumentException> (() => p.MultiplyTransform (noninvertible));
                                }
                        }
                }
@@ -685,10 +666,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void RotateTransform_InvalidOrder ()
                {
-                       default_pen.RotateTransform (720, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => default_pen.RotateTransform (720, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -725,10 +705,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_InvalidOrder ()
                {
-                       default_pen.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => default_pen.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -756,10 +735,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TranslateTransform_InvalidOrder ()
                {
-                       default_pen.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => default_pen.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
index 0b491065b688cbe90fc04a6a3ab1fd3c510052df..e34bc8484646236738ed4dab008eb4c12ec25bad 100644 (file)
@@ -58,13 +58,12 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void RegionData_Null ()
                {
                        RegionData data = new Region ().GetRegionData ();
                        data.Data = null;
                        Assert.IsNull (data.Data, "Data");
-                       Region region = new Region (data);
+                       Assert.Throws<NullReferenceException> (() => new Region (data));
                }
 
                [Test]
index fda32858ec6709ebe341b8c5afc86ea93dbf7d7e..b854d6f5401a5cdc1f025129541b28c11fd07e2c 100644 (file)
@@ -58,12 +58,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Clone ()
                {
                        SolidBrush sb = new SolidBrush (Color.Transparent);
                        sb.Dispose ();
-                       sb.Clone ();
+                       Assert.Throws<ArgumentException> (() => sb.Clone ());
                }
 
                [Test]
index 6811e253df7ef1a64f3ee936fe5a5596567cbccd..9d8c73f321e1cd8c052eb86f03accb3a2352dd9d 100644 (file)
@@ -130,13 +130,12 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Instance ()
                {
                        Font f1 = SystemFonts.CaptionFont;
                        float height = f1.GetHeight (72f);
                        f1.Dispose ();
-                       f1.GetHeight (72f);
+                       Assert.Throws<ArgumentException> (() => f1.GetHeight (72f));
                }
 
                [Test]
index e99d108443dfa91a5728ddb80d66dc82dadd0433..bc5a5d9e9d42a63d09b19aa4c585764b81c237d8 100644 (file)
@@ -62,14 +62,13 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ObjectDisposedException))]
                public void Clone_Dispose ()
                {
                        // Clones of SystemIcons icon's can be disposed
                        Icon app = SystemIcons.Application;
                        Icon clone = (Icon) app.Clone ();
                        clone.Dispose ();
-                       Assert.IsNotNull (clone.ToBitmap ());
+                       Assert.Throws<ObjectDisposedException> (() => clone.ToBitmap ());
                }
        }
 }
index 71fa94ba5874dbea84e8056cdf749a0fe4fdbfd4..fbbbbeaba4cde2bcecad479b6489493fd01738db 100644 (file)
@@ -121,30 +121,24 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void LockBits_IndexedWrite_NonIndexed ()
                {
                        using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format8bppIndexed)) {
                                Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
-                               bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
+                               Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void LockBits_NonIndexedWrite_ToIndexed ()
                {
                        using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
+                               BitmapData bd = new BitmapData ();
                                Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
-                               BitmapData bd = new BitmapData ();
-                               try {
-                                       bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed, bd);
-                               }
-                               catch (ArgumentException) {
-                                       // test to see if there's a leak or not in this case
-                                       Assert.AreEqual (IntPtr.Zero, bd.Scan0, "Scan0");
-                                       throw;
-                               }
+                               Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed, bd));
+
+                               // test to see if there's a leak or not in this case
+                               Assert.AreEqual (IntPtr.Zero, bd.Scan0, "Scan0");
                        }
                }
 
@@ -182,14 +176,13 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
                public void LockBits_Double ()
                {
                        using (Bitmap bmp = new Bitmap (10, 10, PixelFormat.Format24bppRgb)) {
                                Rectangle r = new Rectangle (4, 4, 4, 4);
                                BitmapData data = bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                                try {
-                                       bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
+                                       Assert.Throws<InvalidOperationException> (() => bmp.LockBits (r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb));
                                }
                                finally {
                                        bmp.UnlockBits (data);
@@ -198,17 +191,15 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void LockBits_Disposed ()
                {
                        Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb);
                        Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
                        bmp.Dispose ();
-                       bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
+                       Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("Valgrind")] // this test is known to leak memory (API design limitation)
                public void UnlockBits_Disposed ()
                {
@@ -216,26 +207,24 @@ namespace MonoTests.System.Drawing {
                        Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
                        BitmapData data = bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
                        bmp.Dispose ();
-                       bmp.UnlockBits (data);
+                       Assert.Throws<ArgumentException> (() => bmp.UnlockBits (data));
                        // and that results in something like this when executed under Valgrind 
                        // "40,000 bytes in 1 blocks are possibly lost in loss record 88 of 92"
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void UnlockBits_Null ()
                {
                        using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
-                               bmp.UnlockBits (null);
+                               Assert.Throws<ArgumentException> (() => bmp.UnlockBits (null));
                        }
                }
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void LockBits_BitmapData_Null ()
                {
                        using (Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb)) {
                                Rectangle rect = new Rectangle (0, 0, bmp.Width, bmp.Height);
-                               bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb, null);
+                               Assert.Throws<ArgumentException> (() => bmp.LockBits (rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb, null));
                        }
                }
 
@@ -300,46 +289,42 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
                public void Format1bppIndexed ()
                {
                        using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format1bppIndexed)) {
                                Color c = bmp.GetPixel (0, 0);
                                Assert.AreEqual (-16777216, c.ToArgb (), "Color");
-                               bmp.SetPixel (0, 0, c);
+                               Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
                public void Format4bppIndexed ()
                {
                        using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format4bppIndexed)) {
                                Color c = bmp.GetPixel (0, 0);
                                Assert.AreEqual (-16777216, c.ToArgb (), "Color");
-                               bmp.SetPixel (0, 0, c);
+                               Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
                public void Format8bppIndexed ()
                {
                        using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format8bppIndexed)) {
                                Color c = bmp.GetPixel (0, 0);
                                Assert.AreEqual (-16777216, c.ToArgb (), "Color");
-                               bmp.SetPixel (0, 0, c);
+                               Assert.Throws<InvalidOperationException> (() => bmp.SetPixel (0, 0, c));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")] // libgdiplus doesn't support this format
                public void Format16bppGrayScale ()
                {
                        using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format16bppGrayScale)) {
                                // and MS GDI+ support seems quite limited too
-                               bmp.GetPixel (0, 0);
+                               Assert.Throws<ArgumentException> (() => bmp.GetPixel (0, 0));
                        }
                }
 
@@ -587,10 +572,9 @@ namespace MonoTests.System.Drawing {
                }
                
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FileDoesNotExists ()
                {                       
-                       Bitmap  bmp = new Bitmap ("FileDoesNotExists.jpg");                     
+                       Assert.Throws<ArgumentException> (() => new Bitmap ("FileDoesNotExists.jpg"));                  
                }
 
                static string ByteArrayToString(byte[] arrInput)
@@ -1513,87 +1497,75 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void BitmapImageCtor ()
                {
-                       new Bitmap ((Image) null);
+                       Assert.Throws<NullReferenceException> (() => new Bitmap ((Image) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapImageSizeCtor ()
                {
-                       new Bitmap ((Image) null, Size.Empty);
+                       Assert.Throws<ArgumentException> (() => new Bitmap ((Image) null, Size.Empty));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapImageIntIntCtor ()
                {
-                       new Bitmap ((Image) null, Int32.MinValue, Int32.MaxValue);
+                       Assert.Throws<ArgumentException> (() => new Bitmap ((Image) null, Int32.MinValue, Int32.MaxValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapIntIntCtor ()
                {
-                       new Bitmap (Int32.MinValue, Int32.MaxValue);
+                       Assert.Throws<ArgumentException> (() => new Bitmap (Int32.MinValue, Int32.MaxValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void BitmapIntIntGraphicCtor ()
                {
-                       new Bitmap (1, 1, null);
+                       Assert.Throws<ArgumentNullException> (() => new Bitmap (1, 1, null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapIntIntPixelFormatCtor ()
                {
-                       new Bitmap (Int32.MinValue, Int32.MaxValue, PixelFormat.Format1bppIndexed);
+                       Assert.Throws<ArgumentException> (() => new Bitmap (Int32.MinValue, Int32.MaxValue, PixelFormat.Format1bppIndexed));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapStreamCtor ()
                {
-                       new Bitmap ((Stream) null);
+                       Assert.Throws<ArgumentException> (() => new Bitmap ((Stream) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapStreamBoolCtor ()
                {
-                       new Bitmap ((Stream) null, true);
+                       Assert.Throws<ArgumentException> (() => new Bitmap ((Stream) null, true));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void BitmapStringCtor ()
                {
-                       new Bitmap ((string) null);
+                       Assert.Throws<ArgumentNullException> (() => new Bitmap ((string) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void BitmapStringBoolCtor ()
                {
-                       new Bitmap ((string) null, false);
+                       Assert.Throws<ArgumentNullException> (() => new Bitmap ((string) null, false));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void BitmapTypeStringCtor1 ()
                {
-                       new Bitmap ((Type) null, "mono");
+                       Assert.Throws<NullReferenceException> (() => new Bitmap ((Type) null, "mono"));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BitmapTypeStringCtor2 ()
                {
-                       new Bitmap (typeof (Bitmap), null);
+                       Assert.Throws<ArgumentException> (() => new Bitmap (typeof (Bitmap), null));
                }
 
                private void SetResolution (float x, float y)
@@ -1604,24 +1576,21 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetResolution_Zero ()
                {
-                       SetResolution (0.0f, 0.0f);
+                       Assert.Throws<ArgumentException> (() => SetResolution (0.0f, 0.0f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetResolution_Negative_X ()
                {
-                       SetResolution (-1.0f, 1.0f);
+                       Assert.Throws<ArgumentException> (() => SetResolution (-1.0f, 1.0f));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetResolution_Negative_Y ()
                {
-                       SetResolution (1.0f, -1.0f);
+                       Assert.Throws<ArgumentException> (() => SetResolution (1.0f, -1.0f));
                }
 
                [Test]
@@ -1637,17 +1606,15 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetResolution_NaN ()
                {
-                       SetResolution (Single.NaN, Single.NaN);
+                       Assert.Throws<ArgumentException> (() => SetResolution (Single.NaN, Single.NaN));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetResolution_NegativeInfinity ()
                {
-                       SetResolution (Single.NegativeInfinity, Single.NegativeInfinity);
+                       Assert.Throws<ArgumentException> (() => SetResolution (Single.NegativeInfinity, Single.NegativeInfinity));
                }
        }
 
@@ -1710,13 +1677,12 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")] // libgdiplus has lost track of the original 1bpp state
                public void Hicon48 ()
                {
                        using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/48x48x1.ico"))) {
                                // looks like 1bbp icons aren't welcome as bitmaps ;-)
-                               Bitmap.FromHicon (icon.Handle);
+                               Assert.Throws<ArgumentException> (() => Bitmap.FromHicon (icon.Handle));
                        }
                }
 
index 6b922e2a719b5d228e05d0807c669ca62c7d3e93..4eb5b5b79c4a2831f602830ef4d8c5f23494b239 100644 (file)
@@ -48,12 +48,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose ()
                {
                        Brushes.YellowGreen.Dispose ();
                        // a "normal" SolidBrush would throw an ArgumentException here
-                       Brushes.YellowGreen.Clone ();
+                       Assert.Throws<ArgumentException> (() => Brushes.YellowGreen.Clone ());
                        // and it is! so watch your brushes ;-)
                }
 
index c5df6c531ed3c3e5e5cc19ad810ff06973a200b5..1b6eb6a89f0ae7a574f2e338c2cb3d3a9f0fded9 100644 (file)
@@ -908,12 +908,12 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (1.0f, Color.White.GetBrightness (), "BrightnessWhite");
                
                        Color c1 = Color.FromArgb (0, 13, 45, 7); //just some random color
-                       Assert.IsTrue (       FloatsAlmostEqual (110.5263f, c1.GetHue ()), "Hue1");
+                       Assert.IsTrue (FloatsAlmostEqual (110.5263f, c1.GetHue ()), "Hue1");
                        Assert.IsTrue (FloatsAlmostEqual (0.1019608f, c1.GetBrightness ()), "Brightness1");
                        Assert.IsTrue (FloatsAlmostEqual (0.7307692f, c1.GetSaturation ()), "Saturation1");
        
                        Color c2 = Color.FromArgb (0, 112, 75, 29); //another random color
-                       Assert.IsTrue (       FloatsAlmostEqual (33.25302f, c2.GetHue ()), "Hue2");
+                       Assert.IsTrue (FloatsAlmostEqual (33.25302f, c2.GetHue ()), "Hue2");
                        Assert.IsTrue (FloatsAlmostEqual (0.2764706f, c2.GetBrightness ()), "Brightness2");
                        Assert.IsTrue (FloatsAlmostEqual (0.5886525f, c2.GetSaturation ()), "Saturation2");
                }
@@ -1019,115 +1019,99 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidAlpha1 ()
                {
-                       Color.FromArgb (-1, Color.Red);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (-1, Color.Red));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidAlpha2 ()
                {
-                       Color.FromArgb (256, Color.Red);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (256, Color.Red));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidAlpha3 ()
                {
-                       Color.FromArgb (-1, 0, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (-1, 0, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidAlpha4 ()
                {
-                       Color.FromArgb (256, 0, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (256, 0, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidRed1 ()
                {
-                       Color.FromArgb (-1, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (-1, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidRed2 ()
                {
-                       Color.FromArgb (256, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (256, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidRed3 ()
                {
-                       Color.FromArgb (0, -1, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, -1, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidRed4 ()
                {
-                       Color.FromArgb (0, 256, 0, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 256, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidGreen1 ()
                {
-                       Color.FromArgb (0, -1, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, -1, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidGreen2 ()
                {
-                       Color.FromArgb (0, 256, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 256, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidGreen3 ()
                {
-                       Color.FromArgb (0, 0, -1, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, -1, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidGreen4 ()
                {
-                       Color.FromArgb (0, 0, 256, 0);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, 256, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidBlue1 ()
                {
-                       Color.FromArgb (0, 0, -1);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, -1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidBlue2 ()
                {
-                       Color.FromArgb (0, 0, 256);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, 256));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidBlue3 ()
                {
-                       Color.FromArgb (0, 0, 0, -1);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, 0, -1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromArgb_InvalidBlue4 ()
                {
-                       Color.FromArgb (0, 0, 0, 256);
+                       Assert.Throws<ArgumentException> (() => Color.FromArgb (0, 0, 0, 256));
                }
 
                [Test]
index 50c2f83271f8df98cb9d077aee786ff0b4d33ca4..e1f3660f707e9689ef4ebbd09bbaaecdd32a8528 100644 (file)
@@ -120,7 +120,6 @@ namespace MonoTests.System.Drawing{
 
                [Test]
                [Category ("CAS")]
-               [ExpectedException (typeof (SecurityException))]
                [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
                public void ToLogFont_DenyUnmanagedCode ()
                {
@@ -130,7 +129,7 @@ namespace MonoTests.System.Drawing{
                        lf = new LOGFONT();
                        f = new Font("Arial", 10);
 
-                       f.ToLogFont(lf);
+                       Assert.Throws<SecurityException> (() => f.ToLogFont(lf));
                }
 
                [Test]
@@ -167,12 +166,11 @@ namespace MonoTests.System.Drawing{
 
                [Test]
                [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
-               [ExpectedException (typeof (ArgumentException))]
                public void ToLogFont_TooSmall ()
                {
                        Font f = new Font ("Arial", 10);
                        object o = new object ();
-                       f.ToLogFont (o);
+                       Assert.Throws<ArgumentException> (() => f.ToLogFont (o));
                        // no PInvoke conversion exists !?!?
                }
 
@@ -188,11 +186,10 @@ namespace MonoTests.System.Drawing{
 
                [Test]
                [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
-               [ExpectedException (typeof (AccessViolationException))]
                public void ToLogFont_Null ()
                {
                        Font f = new Font ("Arial", 10);
-                       f.ToLogFont (null);
+                       Assert.Throws<AccessViolationException> (() => f.ToLogFont (null));
                }
                [Test]
                public void Font_StringNull_Float ()
@@ -260,10 +257,9 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Font_String_Float_FontStyle_GraphicsUnit_Display ()
                {
-                       new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display);
+                       Assert.Throws<ArgumentException> (() => new Font (name, 12.5f, FontStyle.Italic, GraphicsUnit.Display));
                }
 
                [Test]
@@ -303,19 +299,17 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Font_FontFamilyNull_Float ()
                {
                        FontFamily ff = null;
-                       new Font (ff, 12.5f);
+                       Assert.Throws<ArgumentNullException> (() => new Font (ff, 12.5f));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Font_FontNull_FontStyle ()
                {
                        Font f = null;
-                       new Font (f, FontStyle.Bold);
+                       Assert.Throws<NullReferenceException> (() => new Font (f, FontStyle.Bold));
                }
 
                [Test]
@@ -373,10 +367,9 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Font_FontFamily_Float_FontStyle_GraphicsUnit_Display ()
                {
-                       new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display);
+                       Assert.Throws<ArgumentException> (() => new Font (FontFamily.GenericMonospace, 12.5f, FontStyle.Italic, GraphicsUnit.Display));
                }
 
                [Test]
@@ -435,22 +428,20 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Height ()
                {
                        Font f = new Font (name, 12.5f);
                        f.Dispose ();
-                       Assert.AreEqual (0, f.Height, "Name");
+                       Assert.Throws<ArgumentException> (() => { var x = f.Height; });
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_ToLogFont ()
                {
                        Font f = new Font (name, 12.5f);
                        f.Dispose ();
                        LOGFONT lf = new LOGFONT();
-                       f.ToLogFont (lf);
+                       Assert.Throws<ArgumentException> (() => f.ToLogFont (lf));
                }
 
                [Test]
@@ -503,22 +494,20 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_ToHFont ()
                {
                        Font f = new Font (name, 12.5f);
                        f.Dispose ();
-                       f.ToHfont ();
+                       Assert.Throws<ArgumentException> (() => f.ToHfont ());
                }
                
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                [Category ("NotWorking")]
                public void UnavailableStyleException ()
                {
                        // Marked NotWorking because it is dependent on what fonts/styles are available
                        // on the OS.  This test is written for Windows.
-                       Font f = new Font ("Monotype Corsiva", 8, FontStyle.Regular);
+                       Assert.Throws<ArgumentException> (() => new Font ("Monotype Corsiva", 8, FontStyle.Regular));
                }
 
                [Test]
@@ -547,11 +536,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void GetHeight_Graphics_Null ()
                {
                        using (Font f = new Font (name, 12.5f)) {
-                               Assert.AreEqual (0, f.GetHeight (null), "0");
+                               Assert.Throws<ArgumentNullException> (() => f.GetHeight (null));
                        }
                }
 
@@ -566,36 +554,36 @@ namespace MonoTests.System.Drawing{
                        Assert.IsFalse (f1.GetHashCode () == f3.GetHashCode (), "2) Fonts with different styles should have different HashCodes");
                }
 
-        [Test]
-        public void GetHashCode_UnitDiffers_HashesNotEqual()
-        {
-            Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point);
-            Font f2 = new Font("Arial", 8.25F, GraphicsUnit.Pixel);
+               [Test]
+               public void GetHashCode_UnitDiffers_HashesNotEqual()
+               {
+                       Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point);
+                       Font f2 = new Font("Arial", 8.25F, GraphicsUnit.Pixel);
 
-            Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(),
-                "Hashcodes should differ if _unit member differs");
-        }
+                       Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(),
+                               "Hashcodes should differ if _unit member differs");
+               }
 
-        [Test]
-        public void GetHashCode_NameDiffers_HashesNotEqual()
-        {
-            Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point);
-            Font f2 = new Font("Courier New", 8.25F, GraphicsUnit.Point);
+               [Test]
+               public void GetHashCode_NameDiffers_HashesNotEqual()
+               {
+                       Font f1 = new Font("Arial", 8.25F, GraphicsUnit.Point);
+                       Font f2 = new Font("Courier New", 8.25F, GraphicsUnit.Point);
 
                        if (f1.Name != f2.Name) {
                                Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(),
                                                           "Hashcodes should differ if _name member differs");
                        }
-        }
+               }
 
-        [Test]
-        public void GetHashCode_StyleEqualsGdiCharSet_HashesNotEqual()
-        {
-            Font f1 = new Font("Arial", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
-            Font f2 = new Font("Arial", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(1)));
+               [Test]
+               public void GetHashCode_StyleEqualsGdiCharSet_HashesNotEqual()
+               {
+                       Font f1 = new Font("Arial", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
+                       Font f2 = new Font("Arial", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(1)));
 
-            Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(),
-                "Hashcodes should differ if _style member differs");
-        }
+                       Assert.IsFalse(f1.GetHashCode() == f2.GetHashCode(),
+                               "Hashcodes should differ if _style member differs");
+               }
        }
 }
index 08264e3f548d459433f03d90e0a9acddd1603de4..1fcacd6a35ae9147b22f24288225b820e3a8d940 100644 (file)
@@ -47,21 +47,19 @@ namespace MonoTests.System.Drawing{
                        Assert.IsTrue (f.GetStandardValuesSupported (), "standard values supported");
                        Assert.IsFalse (f.GetStandardValuesExclusive (), "standard values exclusive");
                }
-               
-               [ExpectedException (typeof (NotSupportedException))]
+
                [Test]
                public void ExTestConvertFrom ()
                {
                        FontConverter.FontNameConverter f = new FontConverter.FontNameConverter ();
-                       f.ConvertFrom (null);
+                       Assert.Throws<NotSupportedException> (() => f.ConvertFrom (null));
                }
 
-               [ExpectedException (typeof (NotSupportedException))]
                [Test]
                public void ExTestConvertFrom2 ()
                {
                        FontConverter.FontNameConverter f = new FontConverter.FontNameConverter ();
-                       f.ConvertFrom (1);
+                       Assert.Throws<NotSupportedException> (() => f.ConvertFrom (1));
                }
        }
 }
index 6f8e3a61406915c6979749fd17fd232663f9df4f..cb8bd1d1b0fc55cbee85bfef5a59a6bd710a7fea 100644 (file)
@@ -379,7 +379,6 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void LoadIndexed_BmpFile ()
                {
                        // Tests that we can load an indexed file, but...
@@ -387,15 +386,14 @@ namespace MonoTests.System.Drawing {
                        // note: file is misnamed (it's a 4bpp bitmap)
                        using (Image img = Image.FromFile (sInFile)) {
                                Assert.AreEqual (PixelFormat.Format4bppIndexed, img.PixelFormat, "PixelFormat");
-                               Graphics.FromImage (img);
+                               Assert.Throws<Exception> (() => Graphics.FromImage (img));
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FromImage ()
                {
-                       Graphics g = Graphics.FromImage (null);
+                       Assert.Throws<ArgumentNullException> (() => Graphics.FromImage (null));
                }
 
                private Graphics Get (int w, int h)
@@ -458,32 +456,29 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Transform_NonInvertibleMatrix ()
                {
                        Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
                        Assert.IsFalse (matrix.IsInvertible, "IsInvertible");
                        Graphics g = Get (16, 16);
-                       g.Transform = matrix;
+                       Assert.Throws<ArgumentException> (() => g.Transform = matrix);
                }
 
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Multiply_NonInvertibleMatrix ()
                {
                        Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
                        Assert.IsFalse (matrix.IsInvertible, "IsInvertible");
                        Graphics g = Get (16, 16);
-                       g.MultiplyTransform (matrix);
+                       Assert.Throws<ArgumentException> (() => g.MultiplyTransform (matrix));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Multiply_Null ()
                {
                        Graphics g = Get (16, 16);
-                       g.MultiplyTransform (null);
+                       Assert.Throws<ArgumentNullException> (() => g.MultiplyTransform (null));
                }
 
                private void CheckBounds (string msg, RectangleF bounds, float x, float y, float w, float h)
@@ -757,19 +752,17 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_X0 ()
                {
                        Graphics g = Get (16, 16);
-                       g.ScaleTransform (0, 1);
+                       Assert.Throws<ArgumentException> (() => g.ScaleTransform (0, 1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_Y0 ()
                {
                        Graphics g = Get (16, 16);
-                       g.ScaleTransform (1, 0);
+                       Assert.Throws<ArgumentException> (() => g.ScaleTransform (1, 0));
                }
 
                [Test]
@@ -814,30 +807,27 @@ namespace MonoTests.System.Drawing {
                static PointF[] LargeCurveF = new PointF[4] { new PointF (0, 0), new PointF (15, 5), new PointF (5, 15), new PointF (0, 20) };
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawCurve_PenNull ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (null, SmallCurveF);
+                       Assert.Throws<ArgumentNullException> (() => g.DrawCurve (null, SmallCurveF));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawCurve_PointFNull ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, (PointF[]) null);
+                       Assert.Throws<ArgumentNullException> (() => g.DrawCurve (Pens.Black, (PointF[]) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawCurve_PointNull ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, (Point[]) null);
+                       Assert.Throws<ArgumentNullException> (() => g.DrawCurve (Pens.Black, (Point[]) null));
                }
 
                [Test]
@@ -855,22 +845,20 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawCurve_SinglePoint ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, new Point[1] { new Point (10, 10) }, 0.5f);
+                       Assert.Throws<ArgumentException> (() => g.DrawCurve (Pens.Black, new Point[1] { new Point (10, 10) }, 0.5f));
                        // a single point isn't enough
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawCurve3_NotEnoughPoints ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, TooSmallCurve, 0, 2, 0.5f);
+                       Assert.Throws<ArgumentException> (() => g.DrawCurve (Pens.Black, TooSmallCurve, 0, 2, 0.5f));
                        // aha, this is API dependent
                }
 
@@ -912,31 +900,28 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawCurve_ZeroSegments ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, SmallCurveF, 0, 0);
+                       Assert.Throws<ArgumentException> (() => g.DrawCurve (Pens.Black, SmallCurveF, 0, 0));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawCurve_NegativeSegments ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.DrawCurve (Pens.Black, SmallCurveF, 0, -1);
+                       Assert.Throws<ArgumentException> (() => g.DrawCurve (Pens.Black, SmallCurveF, 0, -1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawCurve_OffsetTooLarge ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
                        // starting offset 1 doesn't give 3 points to make a curve
-                       g.DrawCurve (Pens.Black, SmallCurveF, 1, 2);
+                       Assert.Throws<ArgumentException> (() => g.DrawCurve (Pens.Black, SmallCurveF, 1, 2));
                        // and in this case 2 points aren't enough to draw something
                }
 
@@ -1205,10 +1190,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BeginContainer_GraphicsUnit_Display ()
                {
-                       BeginContainer_GraphicsUnit (GraphicsUnit.Display);
+                       Assert.Throws<ArgumentException> (() => BeginContainer_GraphicsUnit(GraphicsUnit.Display));
                }
 
                [Test]
@@ -1222,26 +1206,23 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BeginContainer_GraphicsUnit_World ()
                {
-                       BeginContainer_GraphicsUnit (GraphicsUnit.World);
+                       Assert.Throws<ArgumentException> (() => BeginContainer_GraphicsUnit(GraphicsUnit.World));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void BeginContainer_GraphicsUnit_Bad ()
                {
-                       BeginContainer_GraphicsUnit ((GraphicsUnit) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => BeginContainer_GraphicsUnit((GraphicsUnit) Int32.MinValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void EndContainer_Null ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.EndContainer (null);
+                       Assert.Throws<ArgumentNullException> (() => g.EndContainer (null));
                }
 
                [Test]
@@ -1286,76 +1267,69 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Restore_Null ()
                {
                        Bitmap bitmap = new Bitmap (20, 20);
                        Graphics g = Graphics.FromImage (bitmap);
-                       g.Restore (null);
+                       Assert.Throws<NullReferenceException> (() => g.Restore (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillRectangles_BrushNull_Rectangle ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (null, new Rectangle[1]);
+                                       Assert.Throws<ArgumentNullException> (() => g.FillRectangles (null, new Rectangle[1]));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillRectangles_Rectangle_Null ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (Brushes.Red, (Rectangle[]) null);
+                                       Assert.Throws<ArgumentNullException> (() => g.FillRectangles (Brushes.Red, (Rectangle[]) null));
                                }
                        }
                }
 
                [Test] // see bug #78408
-               [ExpectedException (typeof (ArgumentException))]
                public void FillRectanglesZeroRectangle ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (Brushes.Red, new Rectangle[0]);
+                                       Assert.Throws<ArgumentException> (() => g.FillRectangles (Brushes.Red, new Rectangle[0]));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillRectangles_BrushNull_RectangleF ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (null, new RectangleF[1]);
+                                       Assert.Throws<ArgumentNullException> (() => g.FillRectangles (null, new RectangleF[1]));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillRectangles_RectangleF_Null ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (Brushes.Red, (RectangleF[]) null);
+                                       Assert.Throws<ArgumentNullException> (() => g.FillRectangles (Brushes.Red, (RectangleF[]) null));
                                }
                        }
                }
 
                [Test] // see bug #78408
-               [ExpectedException (typeof (ArgumentException))]
                public void FillRectanglesZeroRectangleF ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.FillRectangles (Brushes.Red, new RectangleF[0]);
+                                       Assert.Throws<ArgumentException> (() => g.FillRectangles (Brushes.Red, new RectangleF[0]));
                                }
                        }
                }
@@ -1860,12 +1834,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MeasureString_StringFont_Null ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.MeasureString ("a", null);
+                                       Assert.Throws<ArgumentNullException> (() => g.MeasureString ("a", null));
                                }
                        }
                }
@@ -2157,12 +2130,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MeasureCharacterRanges_FontNull ()
                {
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.MeasureCharacterRanges ("a", null, new RectangleF (), null);
+                                       Assert.Throws<ArgumentNullException> (() => g.MeasureCharacterRanges ("a", null, new RectangleF (), null));
                                }
                        }
                }
@@ -2216,19 +2188,17 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MeasureCharacterRanges_FirstTooFar ()
                {
                        string text = "this\nis a test";
-                       MeasureCharacterRanges (text, text.Length, 1);
+                       Assert.Throws<ArgumentException> (() => MeasureCharacterRanges(text, text.Length, 1));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MeasureCharacterRanges_LengthTooLong ()
                {
                        string text = "this\nis a test";
-                       MeasureCharacterRanges (text, 0, text.Length + 1);
+                       Assert.Throws<ArgumentException> (() => MeasureCharacterRanges(text, 0, text.Length + 1));
                }
 
                [Test]
@@ -2270,7 +2240,6 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MeasureCharacterRanges_NullStringFormat ()
                {
                        if (font == null)
@@ -2278,7 +2247,7 @@ namespace MonoTests.System.Drawing {
 
                        using (Bitmap bitmap = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bitmap)) {
-                                       g.MeasureCharacterRanges ("Mono", font, new RectangleF (), null);
+                                       Assert.Throws<ArgumentException> (() => g.MeasureCharacterRanges ("Mono", font, new RectangleF (), null));
                                }
                        }
                }
@@ -2458,10 +2427,10 @@ namespace MonoTests.System.Drawing {
                }
 
                static CharacterRange [] ranges = new CharacterRange [] {
-                    new CharacterRange (0, 1),
-                    new CharacterRange (1, 1),
-                    new CharacterRange (2, 1)
-                };
+                                       new CharacterRange (0, 1),
+                                       new CharacterRange (1, 1),
+                                       new CharacterRange (2, 1)
+                               };
 
                Region [] Measure (Graphics gfx, RectangleF rect)
                {
@@ -2608,25 +2577,23 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ReleaseHdcInternal_IntPtrZero ()
                {
                        using (Bitmap b = new Bitmap (10, 10)) {
                                using (Graphics g = Graphics.FromImage (b)) {
-                                       g.ReleaseHdcInternal (IntPtr.Zero);
+                                       Assert.Throws<ArgumentException> (() => g.ReleaseHdcInternal (IntPtr.Zero));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ReleaseHdcInternal_TwoTimes ()
                {
                        using (Bitmap b = new Bitmap (10, 10)) {
                                using (Graphics g = Graphics.FromImage (b)) {
                                        IntPtr hdc = g.GetHdc ();
                                        g.ReleaseHdcInternal (hdc);
-                                       g.ReleaseHdcInternal (hdc);
+                                       Assert.Throws<ArgumentException> (() => g.ReleaseHdcInternal (hdc));
                                }
                        }
                }
@@ -2645,25 +2612,23 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TestReleaseHdcException ()
                {
                        using (Bitmap b = new Bitmap (10, 10)) {
                                using (Graphics g = Graphics.FromImage (b)) {
-                                       g.ReleaseHdc ();
+                                       Assert.Throws<ArgumentException> (() => g.ReleaseHdc ());
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TestReleaseHdcException2 ()
                {
                        using (Bitmap b = new Bitmap (10, 10)) {
                                using (Graphics g = Graphics.FromImage (b)) {
                                        g.GetHdc ();
                                        g.ReleaseHdc ();
-                                       g.ReleaseHdc ();
+                                       Assert.Throws<ArgumentException> (() => g.ReleaseHdc ());
                                }
                        }
                }
@@ -2802,12 +2767,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawIcon_NullRectangle ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawIcon (null, new Rectangle (0, 0, 32, 32));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawIcon (null, new Rectangle (0, 0, 32, 32)));
                                }
                        }
                }
@@ -2831,12 +2795,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawIcon_NullIntInt ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawIcon (null, 4, 2);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawIcon (null, 4, 2));
                                }
                        }
                }
@@ -2853,12 +2816,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawIconUnstretched_NullRectangle ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawIconUnstretched (null, new Rectangle (0, 0, 40, 20));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawIconUnstretched (null, new Rectangle (0, 0, 40, 20)));
                                }
                        }
                }
@@ -2882,12 +2844,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullRectangleF ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new RectangleF (0, 0, 0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new RectangleF (0, 0, 0, 0)));
                                }
                        }
                }
@@ -2906,12 +2867,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPointF ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new PointF (0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new PointF (0, 0)));
                                }
                        }
                }
@@ -2927,34 +2887,31 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPointFArray ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new PointF[0]);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new PointF[0]));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_ImagePointFArrayNull ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, (PointF[]) null);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (bmp, (PointF[]) null));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePointFArrayEmpty ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, new PointF[0]);
+                                       Assert.Throws<ArgumentException> (() => g.DrawImage (bmp, new PointF[0]));
                                }
                        }
                }
@@ -2971,12 +2928,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullRectangle ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new Rectangle (0, 0, 0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new Rectangle (0, 0, 0, 0)));
                                }
                        }
                }
@@ -2999,12 +2955,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPoint ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new Point (0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new Point (0, 0)));
                                }
                        }
                }
@@ -3020,34 +2975,31 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPointArray ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new Point[0]);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new Point[0]));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_ImagePointArrayNull ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, (Point[]) null);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (bmp, (Point[]) null));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePointArrayEmpty ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, new Point[0]);
+                                       Assert.Throws<ArgumentException> (() => g.DrawImage (bmp, new Point[0]));
                                }
                        }
                }
@@ -3064,23 +3016,21 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullIntInt ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, Int32.MaxValue, Int32.MinValue);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, Int32.MaxValue, Int32.MinValue));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
                public void DrawImage_ImageIntInt_Overflow ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, Int32.MaxValue, Int32.MinValue);
+                                       Assert.Throws<OverflowException> (() => g.DrawImage (bmp, Int32.MaxValue, Int32.MinValue));
                                }
                        }
                }
@@ -3096,23 +3046,21 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullFloat ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, Single.MaxValue, Single.MinValue);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, Single.MaxValue, Single.MinValue));
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
                public void DrawImage_ImageFloatFloat_Overflow ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (bmp, Single.MaxValue, Single.MinValue);
+                                       Assert.Throws<OverflowException> (() => g.DrawImage (bmp, Single.MaxValue, Single.MinValue));
                                }
                        }
                }
@@ -3128,12 +3076,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullRectangleRectangleGraphicsUnit ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, new Rectangle (), new Rectangle (), GraphicsUnit.Display);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, new Rectangle (), new Rectangle (), GraphicsUnit.Display));
                                }
                        }
                }
@@ -3149,31 +3096,27 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_Display ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Display);
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Display));
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_Document ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Document);
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Document));
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_Inch ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Inch);
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit(GraphicsUnit.Inch));
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_Millimeter ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Millimeter);
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Millimeter));
                }
 
                [Test]
@@ -3184,28 +3127,25 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_Point ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Point);
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.Point));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImageRectangleRectangleGraphicsUnit_World ()
                {
-                       DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.World);
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImageRectangleRectangleGraphicsUnit (GraphicsUnit.World));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPointRectangleGraphicsUnit ()
                {
                        Rectangle r = new Rectangle (1, 2, 3, 4);
                        Point[] pts = new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) };
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, pts, r, GraphicsUnit.Pixel);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, pts, r, GraphicsUnit.Pixel));
                                }
                        }
                }
@@ -3221,33 +3161,29 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_ImageNullRectangleGraphicsUnit ()
                {
-                       DrawImage_ImagePointRectangleGraphicsUnit (null);
+                       Assert.Throws<ArgumentNullException> (() => DrawImage_ImagePointRectangleGraphicsUnit (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePoint0RectangleGraphicsUnit ()
                {
-                       DrawImage_ImagePointRectangleGraphicsUnit (new Point[0]);
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointRectangleGraphicsUnit (new Point[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePoint1RectangleGraphicsUnit ()
                {
                        Point p = new Point (1, 1);
-                       DrawImage_ImagePointRectangleGraphicsUnit (new Point[1] { p });
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointRectangleGraphicsUnit (new Point[1] { p }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePoint2RectangleGraphicsUnit ()
                {
                        Point p = new Point (1, 1);
-                       DrawImage_ImagePointRectangleGraphicsUnit (new Point[2] { p, p });
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointRectangleGraphicsUnit (new Point[2] { p, p }));
                }
 
                [Test]
@@ -3258,22 +3194,20 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImagePoint4RectangleGraphicsUnit ()
                {
                        Point p = new Point (1, 1);
-                       DrawImage_ImagePointRectangleGraphicsUnit (new Point[4] { p, p, p, p });
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImagePointRectangleGraphicsUnit (new Point[4] { p, p, p, p }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_NullPointFRectangleGraphicsUnit ()
                {
                        Rectangle r = new Rectangle (1, 2, 3, 4);
                        PointF[] pts = new PointF[3] { new PointF (1, 1), new PointF (2, 2), new PointF (3, 3) };
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImage (null, pts, r, GraphicsUnit.Pixel);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImage (null, pts, r, GraphicsUnit.Pixel));
                                }
                        }
                }
@@ -3289,33 +3223,29 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImage_ImageNullFRectangleGraphicsUnit ()
                {
-                       DrawImage_ImagePointFRectangleGraphicsUnit (null);
+                       Assert.Throws<ArgumentNullException> (() => DrawImage_ImagePointFRectangleGraphicsUnit (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePointF0RectangleGraphicsUnit ()
                {
-                       DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[0]);
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[0]));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePointF1RectangleGraphicsUnit ()
                {
                        PointF p = new PointF (1, 1);
-                       DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[1] { p });
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[1] { p }));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void DrawImage_ImagePointF2RectangleGraphicsUnit ()
                {
                        PointF p = new PointF (1, 1);
-                       DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[2] { p, p });
+                       Assert.Throws<ArgumentException> (() => DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[2] { p, p }));
                }
 
                [Test]
@@ -3326,11 +3256,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NotImplementedException))]
                public void DrawImage_ImagePointF4RectangleGraphicsUnit ()
                {
                        PointF p = new PointF (1, 1);
-                       DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[4] { p, p, p, p });
+                       Assert.Throws<NotImplementedException> (() => DrawImage_ImagePointFRectangleGraphicsUnit (new PointF[4] { p, p, p, p }));
                }
 
                [Test]
@@ -3361,12 +3290,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImageUnscaled_NullPoint ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImageUnscaled (null, new Point (0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImageUnscaled (null, new Point (0, 0)));
                                }
                        }
                }
@@ -3382,12 +3310,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImageUnscaled_NullRectangle ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImageUnscaled (null, new Rectangle (0, 0, -1, -1));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImageUnscaled (null, new Rectangle (0, 0, -1, -1)));
                                }
                        }
                }
@@ -3403,12 +3330,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImageUnscaled_NullIntInt ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImageUnscaled (null, 0, 0);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImageUnscaled (null, 0, 0));
                                }
                        }
                }
@@ -3424,12 +3350,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImageUnscaled_NullIntIntIntInt ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImageUnscaled (null, 0, 0, -1, -1);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImageUnscaled (null, 0, 0, -1, -1));
                                }
                        }
                }
@@ -3444,12 +3369,11 @@ namespace MonoTests.System.Drawing {
                        }
                }
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawImageUnscaledAndClipped_Null ()
                {
                        using (Bitmap bmp = new Bitmap (40, 40)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawImageUnscaledAndClipped (null, new Rectangle (0, 0, 0, 0));
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawImageUnscaledAndClipped (null, new Rectangle (0, 0, 0, 0)));
                                }
                        }
                }
@@ -3476,25 +3400,23 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawPath_Pen_Null ()
                {
                        using (Bitmap bmp = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
                                        using (GraphicsPath path = new GraphicsPath ()) {
-                                               g.DrawPath (null, path);
+                                               Assert.Throws<ArgumentNullException> (() => g.DrawPath (null, path));
                                        }
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void DrawPath_Path_Null ()
                {
                        using (Bitmap bmp = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.DrawPath (Pens.Black, null);
+                                       Assert.Throws<ArgumentNullException> (() => g.DrawPath (Pens.Black, null));
                                }
                        }
                }
@@ -3529,25 +3451,23 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillPath_Brush_Null ()
                {
                        using (Bitmap bmp = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
                                        using (GraphicsPath path = new GraphicsPath ()) {
-                                               g.FillPath (null, path);
+                                               Assert.Throws<ArgumentNullException> (() => g.FillPath (null, path));
                                        }
                                }
                        }
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void FillPath_Path_Null ()
                {
                        using (Bitmap bmp = new Bitmap (20, 20)) {
                                using (Graphics g = Graphics.FromImage (bmp)) {
-                                       g.FillPath (Brushes.Black, null);
+                                       Assert.Throws<ArgumentNullException> (() => g.FillPath (Brushes.Black, null));
                                }
                        }
                }
index b24af54e3d6d9cfb3b944fd5dc2896c3b28c4e87..e4d0fa0758d671f385ac3d7a7f671878946ccd1d 100644 (file)
@@ -29,6 +29,7 @@
 //
 
 using System;
+using System.ComponentModel;
 using System.Drawing;
 using System.Drawing.Imaging;
 using System.IO;
@@ -93,10 +94,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_IconNull_Int_Int ()
                {
-                       new Icon ((Icon)null, 32, 32);
+                       Assert.Throws<ArgumentException> (() => new Icon ((Icon)null, 32, 32));
                }
 
                [Test]
@@ -108,10 +108,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_IconNull_Size ()
                {
-                       new Icon ((Icon) null, new Size (32, 32));
+                       Assert.Throws<ArgumentException> (() => new Icon ((Icon) null, new Size (32, 32)));
                }
 
                [Test]
@@ -173,58 +172,50 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_StreamNull ()
                {
-                       new Icon ((Stream) null);
+                       Assert.Throws<ArgumentException> (() => new Icon ((Stream) null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_StreamNull_Int_Int ()
                {
-                       new Icon ((Stream) null, 32, 32);
+                       Assert.Throws<ArgumentException> (() => new Icon ((Stream) null, 32, 32));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_StringNull ()
                {
-                       new Icon ((string) null);
+                       Assert.Throws<ArgumentNullException> (() => new Icon ((string) null));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Constructor_TypeNull_String ()
                {
-                       new Icon ((Type) null, "mono.ico");
+                       Assert.Throws<NullReferenceException> (() => new Icon ((Type) null, "mono.ico"));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_Type_StringNull ()
                {
-                       new Icon (typeof (Icon), null);
+                       Assert.Throws<ArgumentException> (() => new Icon (typeof (Icon), null));
                }
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Constructor_StreamNull_Size ()
                {
-                       new Icon ((Stream) null, new Size (32, 32));
+                       Assert.Throws<ArgumentException> (() => new Icon ((Stream) null, new Size (32, 32)));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_StringNull_Size ()
                {
-                       new Icon ((string) null, new Size (32, 32));
+                       Assert.Throws<ArgumentNullException> (() => new Icon ((string) null, new Size (32, 32)));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_StringNull_Int_Int ()
                {
-                       new Icon ((string) null, 32, 32);
+                       Assert.Throws<ArgumentNullException> (() => new Icon ((string) null, 32, 32));
                }
 
                [Test]
@@ -380,10 +371,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void Save_Null ()
                {
-                       icon.Save (null);
+                       Assert.Throws<NullReferenceException> (() => icon.Save (null));
                }
 
                [Test]
@@ -499,34 +489,31 @@ namespace MonoTests.System.Drawing {
                        }
                }
 
-               [Test, ExpectedException ()] //ToDo: System.ComponentModel.Win32Exception
+               [Test]
                public void Only256InFile ()
                {
                        using (FileStream fs = File.OpenRead (TestBitmap.getInFile ("bitmaps/only256.ico"))) {
-                               Icon icon = new Icon (fs, 0, 0);
+                               Assert.Throws<Win32Exception> (() => new Icon (fs, 0, 0));
                        }
                }
 
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ExtractAssociatedIcon_Null ()
                {
-                       Icon.ExtractAssociatedIcon (null);
+                       Assert.Throws<ArgumentException> (() => Icon.ExtractAssociatedIcon (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ExtractAssociatedIcon_Empty ()
                {
-                       Icon.ExtractAssociatedIcon (String.Empty);
+                       Assert.Throws<ArgumentException> (() => Icon.ExtractAssociatedIcon (String.Empty));
                }
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                public void ExtractAssociatedIcon_DoesNotExists ()
                {
-                       Icon.ExtractAssociatedIcon ("does-not-exists.png");
+                       Assert.Throws<FileNotFoundException> (() => Icon.ExtractAssociatedIcon ("does-not-exists.png"));
                }
 
                private static bool RunningOnUnix {
index e064a4337a3e551072f28241e66773d459380806..c53d061bad056434bb99b5d5871f1cc8fe2155dc 100644 (file)
@@ -69,10 +69,9 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (FileNotFoundException))]
                public void FileDoesNotExists ()
                {
-                       Image.FromFile ("FileDoesNotExists.jpg");
+                       Assert.Throws<FileNotFoundException> (() => Image.FromFile ("FileDoesNotExists.jpg"));
                }
 
                private bool CallbackTrue ()
@@ -101,20 +100,18 @@ namespace MonoTests.System.Drawing{
                }
 
                [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));
                        }
                }
 
@@ -245,13 +242,12 @@ namespace MonoTests.System.Drawing{
 
                [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));
                        }
                }
 
@@ -287,31 +283,28 @@ namespace MonoTests.System.Drawing{
 
                [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));
                        }
                }
 
@@ -350,7 +343,6 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void StreamJunkSaveLoad ()
                {
                        using (MemoryStream ms = new MemoryStream ()) {
@@ -363,7 +355,7 @@ namespace MonoTests.System.Drawing{
                                        bmp.Save (ms, ImageFormat.Bmp);
                                        Assert.IsTrue (ms.Position > 2, "Position-2");
                                        // exception here
-                                       Image.FromStream (ms);
+                                       Assert.Throws<ArgumentException> (() => Image.FromStream (ms));
                                }
                        }
                }
index ef4752ae037eaccc191d62b224780afd9190bc8a..33d4b51d1df52528f16e6869d8ac97d95354bb01 100644 (file)
@@ -157,87 +157,75 @@ namespace MonoTests.System.Drawing
                }
                
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_BadString ()
                {
-                       imgConv.ConvertFrom ("System.Drawing.String");
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom ("System.Drawing.String"));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_BadString_WithCulture ()
                {
-                       imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, "System.Drawing.String");
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, "System.Drawing.String"));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_Bitmap ()
                {
-                       imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Bitmap (20, 20));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Bitmap (20, 20)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_Point ()
                {
-                       imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Point (10, 10));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Point (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_SizeF ()
                {
-                       imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new SizeF (10, 10));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new SizeF (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertFrom_Object ()
                {
-                       imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Object ());
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, new Object ()));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_BadString ()
                {
-                       imgConvFrmTD.ConvertFrom ("System.Drawing.String");
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom ("System.Drawing.String"));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_BadString_Culture ()
                {
-                       imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, "System.Drawing.String");
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, "System.Drawing.String"));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_Bitmap ()
                {
-                       imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Bitmap (20, 20));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Bitmap (20, 20)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_Point ()
                {
-                       imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Point (10, 10));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Point (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_SizeF ()
                {
-                       imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new SizeF (10, 10));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new SizeF (10, 10)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertFrom_Object ()
                {
-                       imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Object ());
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, new Object ()));
                }
 
                [Test]
@@ -278,115 +266,99 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Rectangle ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Rectangle));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Rectangle)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Image ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, image.GetType ());
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, image.GetType ()));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Size ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Size));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Size)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Bitmap ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Bitmap));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Bitmap)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Point ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Point));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Point)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Metafile ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Metafile));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Metafile)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Object ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Object));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Object)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void ConvertTo_Int ()
                {
-                       imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (int));
+                       Assert.Throws<NotSupportedException> (() => imgConv.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (int)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Rectangle ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Rectangle));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Rectangle)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Image ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, image.GetType ());
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, image.GetType ()));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Size ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Size));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Size)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Bitmap ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Bitmap));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Bitmap)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Point ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Point));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Point)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Metafile ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Metafile));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Metafile)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Object ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Object));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (Object)));
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
                public void TypeDescriptor_ConvertTo_Int ()
                {
-                       imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (int));
+                       Assert.Throws<NotSupportedException> (() => imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture, image, typeof (int)));
                }
 
                [Test]
index 0a0a6d0914fc7c5eb57f621f819c3343e840b775..7b5ec27a8576b5ffeaf3e6bb851b6bcfde840684 100644 (file)
@@ -253,13 +253,12 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TestCreateInstance_CaseSensitive ()
                {
                        Hashtable ht = new Hashtable ();
                        ht.Add ("x", 2);
                        ht.Add ("Y", 3);
-                       ptconv.CreateInstance (null, ht);
+                       Assert.Throws<ArgumentException> (() => ptconv.CreateInstance (null, ht));
                }
 
                [Test]
@@ -305,10 +304,9 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromInvariantString_string_exc_1 ()
                {
-                       ptconv.ConvertFromInvariantString ("1");
+                       Assert.Throws<ArgumentException> (() => ptconv.ConvertFromInvariantString ("1"));
                }
 
                [Test]
@@ -341,10 +339,9 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromString_string_exc_1 ()
                {
-                       ptconv.ConvertFromString ("1");
+                       Assert.Throws<ArgumentException> (() => ptconv.ConvertFromString ("1"));
                }
 
                [Test]
index aa0b9e68ae9ece01725a1c25219b7f87529c4d7c..f75a06926d16ee8baff64901c0f4093057b90ece 100644 (file)
@@ -305,7 +305,6 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TestCreateInstance_CaseSensitive ()
                {
                        Hashtable ht = new Hashtable ();
@@ -313,7 +312,7 @@ namespace MonoTests.System.Drawing
                        ht.Add ("Y", -10);
                        ht.Add ("Width", 20);
                        ht.Add ("Height", 30);
-                       rconv.CreateInstance (null, ht);
+                       Assert.Throws<ArgumentException> (() => rconv.CreateInstance (null, ht));
                }
 
                [Test]
@@ -374,10 +373,9 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromInvariantString_string_exc_1 ()
                {
-                       rconv.ConvertFromInvariantString ("1, 2, 3");
+                       Assert.Throws<ArgumentException> (() => rconv.ConvertFromInvariantString ("1, 2, 3"));
                }
 
                [Test]
@@ -410,12 +408,11 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromString_string_exc_1 ()
                {
                        CultureInfo culture = CultureInfo.CurrentCulture;
-                       rconv.ConvertFromString (string.Format(culture,
-                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+                       Assert.Throws<ArgumentException> (() => rconv.ConvertFromString (string.Format(culture,
+                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator)));
                }
 
                [Test]
index d57515cab06ed34b08b443c7f5f066929786c00f..86f99ad338a0ae23eee719273da2a88f053bb8f7 100644 (file)
@@ -1048,35 +1048,31 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       Region r = new Region (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Constructor_RegionData_Null ()
                {
                        RegionData rd = null;
-                       Region r = new Region (rd);
+                       Assert.Throws<ArgumentNullException> (() => new Region (rd));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Union_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new Region ().Union (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Union (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Union_Region_Null ()
                {
                        Region r = null;
-                       new Region ().Union (r);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Union (r));
                }
 
                [Test]
@@ -1091,74 +1087,65 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Intersect_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new Region ().Intersect (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Intersect (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Intersect_Region_Null ()
                {
                        Region r = null;
-                       new Region ().Intersect (r);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Intersect (r));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Complement_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new Region ().Complement (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Complement (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Complement_Region_Null ()
                {
                        Region r = null;
-                       new Region ().Complement (r);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Complement (r));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Exclude_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new Region ().Exclude (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Exclude (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Exclude_Region_Null ()
                {
                        Region r = null;
-                       new Region ().Exclude (r);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Exclude (r));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Xor_GraphicsPath_Null ()
                {
                        GraphicsPath gp = null;
-                       new Region ().Xor (gp);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Xor (gp));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Xor_Region_Null ()
                {
                        Region r = null;
-                       new Region ().Xor (r);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Xor (r));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void GetBounds_Null ()
                {
-                       new Region ().GetBounds (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().GetBounds (null));
                }
 
                [Test]
@@ -1214,53 +1201,46 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsEmpty_Null ()
                {
-                       new Region ().IsEmpty (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().IsEmpty (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void IsInfinite_Null ()
                {
-                       new Region ().IsInfinite (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().IsInfinite (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Equals_NullGraphics ()
                {
-                       new Region ().Equals (null, Graphics.FromImage (new Bitmap (10, 10)));
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Equals (null, Graphics.FromImage (new Bitmap (10, 10))));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Equals_RegionNull ()
                {
-                       new Region ().Equals (new Region (), null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Equals (new Region (), null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                [Category ("NotWorking")] // caused regression in SWF
                public void GetHrgn_Null ()
                {
-                       new Region ().GetHrgn (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().GetHrgn (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void GetRegionScans_Null ()
                {
-                       new Region ().GetRegionScans (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().GetRegionScans (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       new Region ().Transform (null);
+                       Assert.Throws<ArgumentNullException> (() => new Region ().Transform (null));
                }
 
                // an "empty ctor" Region is infinite
@@ -1575,17 +1555,15 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void FromHrgn_Zero ()
                {
-                       Region.FromHrgn (IntPtr.Zero);
+                       Assert.Throws<ArgumentException> (() => Region.FromHrgn (IntPtr.Zero));
                }
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void ReleaseHrng_Zero ()
                {
                        Region r = new Region (new GraphicsPath ());
-                       r.ReleaseHrgn (IntPtr.Zero);
+                       Assert.Throws<ArgumentNullException> (() => r.ReleaseHrgn (IntPtr.Zero));
                }
 
                [Test]
index 7e10230544ae01cc9e83d2776640e34d491235a4..03a986cea8aa67e43bc07928b04cce92a4ecac23 100644 (file)
@@ -256,13 +256,12 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TestCreateInstance_CaseSensitive ()
                {
                        Hashtable ht = new Hashtable ();
                        ht.Add ("width", 20);
                        ht.Add ("Height", 30);
-                       szconv.CreateInstance (null, ht);
+                       Assert.Throws<ArgumentException> (() => szconv.CreateInstance (null, ht));
                }
 
                [Test]
@@ -310,10 +309,9 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromInvariantString_string_exc_1 ()
                {
-                       szconv.ConvertFromInvariantString ("1, 2, 3");
+                       Assert.Throws<ArgumentException> (() => szconv.ConvertFromInvariantString ("1, 2, 3"));
                }
 
                [Test]
@@ -346,12 +344,11 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromString_string_exc_1 ()
                {
                        CultureInfo culture = CultureInfo.CurrentCulture;
-                       szconv.ConvertFromString (string.Format(culture,
-                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+                       Assert.Throws<ArgumentException> (() => szconv.ConvertFromString (string.Format(culture,
+                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator)));
                }
 
                [Test]
index 3277b2281cf969d80f5a80bf5579cc448a43a84f..67714cf26401f57f2d11016f2322c3259deaf3c1 100644 (file)
@@ -250,23 +250,21 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidCastException))]
                public void TestCreateInstance_Int ()
                {
                        Hashtable ht = new Hashtable ();
                        ht.Add ("Width", 10);
                        ht.Add ("Height", 20);
-                       szconv.CreateInstance (null, ht);
+                       Assert.Throws<InvalidCastException> (() => szconv.CreateInstance (null, ht));
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void TestCreateInstance_CaseSensitive ()
                {
                        Hashtable ht = new Hashtable ();
                        ht.Add ("width", 20);
                        ht.Add ("Height", 30);
-                       szconv.CreateInstance (null, ht);
+                       Assert.Throws<NullReferenceException> (() => szconv.CreateInstance (null, ht));
                }
 
                [Test]
@@ -314,10 +312,9 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromInvariantString_string_exc_1 ()
                {
-                       szconv.ConvertFromInvariantString ("1, 2, 3");
+                       Assert.Throws<ArgumentException> (() => szconv.ConvertFromInvariantString ("1, 2, 3"));
                }
 
                [Test]
@@ -350,12 +347,11 @@ namespace MonoTests.System.Drawing
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ConvertFromString_string_exc_1 ()
                {
                        CultureInfo culture = CultureInfo.CurrentCulture;
-                       szconv.ConvertFromString (string.Format(culture,
-                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+                       Assert.Throws<ArgumentException> (() => szconv.ConvertFromString (string.Format(culture,
+                               "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator)));
                }
 
                [Test]
index e8b68c56f4d3eaf7702952dde3af77ea941fe6c2..6e20da75335b9320fe45509ad510dfd993367e40 100644 (file)
@@ -66,19 +66,17 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Default_Dispose ()
                {
                        StringFormat sf = new StringFormat ();
                        sf.Dispose ();
-                       sf.ToString ();
+                       Assert.Throws<ArgumentException> (() => sf.ToString ());
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void ctor_StringFormat_Null ()
                {
-                       new StringFormat (null);
+                       Assert.Throws<ArgumentNullException> (() => new StringFormat (null));
                }
 
                [Test]
@@ -120,12 +118,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void GenericDefault_Local_Dispose ()
                {
                        StringFormat sf = StringFormat.GenericDefault;
                        sf.Dispose (); // can't be cached
-                       CheckDefaults (sf);
+                       Assert.Throws<ArgumentException> (() => CheckDefaults (sf));
                }
 
                private void CheckTypographic (StringFormat sf)
@@ -155,12 +152,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void GenericTypographic_Local_Dispose ()
                {
                        StringFormat sf = StringFormat.GenericTypographic;
                        sf.Dispose (); // can't be cached
-                       CheckTypographic (sf);
+                       Assert.Throws<ArgumentException> (() => CheckTypographic (sf));
                }
 
                [Test]
@@ -175,11 +171,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void Alignment_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.Alignment = (StringAlignment) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.Alignment = (StringAlignment) Int32.MinValue);
                        }
                }
 
@@ -195,11 +190,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void HotkeyPrefix_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.HotkeyPrefix = (HotkeyPrefix) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.HotkeyPrefix = (HotkeyPrefix) Int32.MinValue);
                        }
                }
 
@@ -215,11 +209,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void LineAlignment_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.LineAlignment = (StringAlignment) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.LineAlignment = (StringAlignment) Int32.MinValue);
                        }
                }
 
@@ -235,11 +228,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void Trimming_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.Trimming = (StringTrimming) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.Trimming = (StringTrimming) Int32.MinValue);
                        }
                }
 
@@ -311,11 +303,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void SetTabStops_Null ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.SetTabStops (Single.NaN, null);
+                               Assert.Throws<NullReferenceException> (() => sf.SetTabStops (Single.NaN, null));
                        }
                }
 
@@ -330,11 +321,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
                public void SetMeasurableCharacterRanges_Null ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.SetMeasurableCharacterRanges (null);
+                               Assert.Throws<NullReferenceException> (() => sf.SetMeasurableCharacterRanges (null));
                        }
                }
 
@@ -357,12 +347,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
                public void SetMeasurableCharacterRanges_TooBig ()
                {
                        using (StringFormat sf = new StringFormat ()) {
                                CharacterRange[] range = new CharacterRange[33];
-                               sf.SetMeasurableCharacterRanges (range);
+                               Assert.Throws<OverflowException> (() => sf.SetMeasurableCharacterRanges (range));
                        }
                }
        }
index cc2dcd23ea94999a23aeb578f9ef9a1502d4c22d..f5b342291daa7ea7a563bc96b2bc0cc801143566 100644 (file)
@@ -67,10 +67,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null ()
                {
-                       new TextureBrush (null);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null));
                }
 
                [Test]
@@ -81,10 +80,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null_WrapMode ()
                {
-                       new TextureBrush (null, WrapMode.Clamp);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null, WrapMode.Clamp));
                }
 
                [Test]
@@ -97,24 +95,21 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void CtorImageWrapMode_Invalid ()
                {
-                       new TextureBrush (image, (WrapMode) Int32.MinValue);
+                       Assert.Throws<InvalidEnumArgumentException> (() => new TextureBrush (image, (WrapMode) Int32.MinValue));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null_Rectangle ()
                {
-                       new TextureBrush (null, rect);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null, rect));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CtorImageRectangle_Empty ()
                {
-                       new TextureBrush (image, new Rectangle ());
+                       Assert.Throws<OutOfMemoryException> (() => new TextureBrush (image, new Rectangle ()));
                }
 
                [Test]
@@ -125,17 +120,15 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null_RectangleF ()
                {
-                       new TextureBrush (null, rectf);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null, rectf));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CtorImageRectangleF_Empty ()
                {
-                       new TextureBrush (image, new RectangleF ());
+                       Assert.Throws<OutOfMemoryException> (() => new TextureBrush (image, new RectangleF ()));
                }
 
                [Test]
@@ -146,17 +139,15 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null_RectangleAttributes ()
                {
-                       new TextureBrush (null, rect, attr);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null, rect, attr));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CtorImageRectangle_Empty_Attributes ()
                {
-                       new TextureBrush (image, new Rectangle (), attr);
+                       Assert.Throws<OutOfMemoryException> (() => new TextureBrush (image, new Rectangle (), attr));
                }
 
                [Test]
@@ -174,17 +165,15 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void CtorImage_Null_RectangleFAttributes ()
                {
-                       new TextureBrush (null, rectf, attr);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (null, rectf, attr));
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void CtorImageRectangleF_Empty_Attributes ()
                {
-                       new TextureBrush (image, new RectangleF ());
+                       Assert.Throws<OutOfMemoryException> (() => new TextureBrush (image, new RectangleF ()));
                }
 
                [Test]
@@ -211,10 +200,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void CtorImageWrapMode_Invalid_Rectangle ()
                {
-                       new TextureBrush (image, (WrapMode) Int32.MinValue, rect);
+                       Assert.Throws<InvalidEnumArgumentException> (() => new TextureBrush (image, (WrapMode) Int32.MinValue, rect));
                }
 
                [Test]
@@ -227,10 +215,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void CtorImageWrapMode_Invalid_RectangleF ()
                {
-                       new TextureBrush (image, (WrapMode) Int32.MinValue, rectf);
+                       Assert.Throws<InvalidEnumArgumentException> (() => new TextureBrush (image, (WrapMode) Int32.MinValue, rectf));
                }
 
                [Test]
@@ -249,20 +236,18 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (OutOfMemoryException))]
                public void TextureBush_RectangleOutsideBitmap ()
                {
                        Rectangle r = new Rectangle (50, 50, 50, 50);
                        Assert.IsFalse (r.Y + r.Height <= bmp.Height, "Height");
                        Assert.IsFalse (r.X + r.Width <= bmp.Width, "Width");
-                       new TextureBrush (bmp, r);
+                       Assert.Throws<OutOfMemoryException> (() => new TextureBrush (bmp, r));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void Transform_Null ()
                {
-                       new TextureBrush (image).Transform = null;
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (image).Transform = null);
                }
 
                [Test]
@@ -285,10 +270,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
                public void WrapMode_Invalid ()
                {
-                       new TextureBrush (image).WrapMode = (WrapMode)Int32.MinValue;
+                       Assert.Throws<InvalidEnumArgumentException> (() => new TextureBrush (image).WrapMode = (WrapMode)Int32.MinValue);
                }
 
                [Test]
@@ -300,12 +284,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Clone ()
                {
                        TextureBrush t = new TextureBrush (image);
                        t.Dispose ();
-                       t.Clone ();
+                       Assert.Throws<ArgumentException> (() => t.Clone ());
                }
 
                [Test]
@@ -318,26 +301,23 @@ namespace MonoTests.System.Drawing {
 
                [Test]
                [NUnit.Framework.Category ("NotDotNet")] // AccessViolationException under 2.0
-               [ExpectedException (typeof (ArgumentException))]
                public void Dispose_Image ()
                {
                        TextureBrush t = new TextureBrush (image);
                        t.Dispose ();
-                       Assert.IsNotNull (t.Image, "Image");
+                       Assert.Throws<ArgumentException> (() => Assert.IsNotNull (t.Image, "Image"));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform_Null ()
                {
-                       new TextureBrush (image).MultiplyTransform (null);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (image).MultiplyTransform (null));
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
                public void MultiplyTransform_Null_Order ()
                {
-                       new TextureBrush (image).MultiplyTransform (null, MatrixOrder.Append);
+                       Assert.Throws<ArgumentNullException> (() => new TextureBrush (image).MultiplyTransform (null, MatrixOrder.Append));
                }
 
                [Test]
@@ -348,12 +328,11 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void MultiplyTransform_NonInvertible ()
                {
                        TextureBrush t = new TextureBrush (image);
                        Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30);
-                       t.MultiplyTransform (noninvertible);
+                       Assert.Throws<ArgumentException> (() => t.MultiplyTransform (noninvertible));
                }
 
                [Test]
@@ -384,11 +363,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void RotateTransform_InvalidOrder ()
                {
                        TextureBrush t = new TextureBrush (image);
-                       t.RotateTransform (720, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => t.RotateTransform (720, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -423,11 +401,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void ScaleTransform_InvalidOrder ()
                {
                        TextureBrush t = new TextureBrush (image);
-                       t.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => t.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                [Test]
@@ -454,11 +431,10 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void TranslateTransform_InvalidOrder ()
                {
                        TextureBrush t = new TextureBrush (image);
-                       t.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
+                       Assert.Throws<ArgumentException> (() => t.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue));
                }
 
                private void Alpha_81828 (WrapMode mode, bool equals)