Make System.Drawing unit tests use Assert.Throws instead of [ExpectedException] ...
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / PenTest.cs
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]