Make System.Drawing unit tests use Assert.Throws instead of [ExpectedException] ...
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / TestStringFormat.cs
index 31aaf102111b94680eec9e14249229a4a0c5442a..6e20da75335b9320fe45509ad510dfd993367e40 100644 (file)
@@ -66,22 +66,17 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                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]
@@ -93,9 +88,6 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void ctor_StringFormatFlags ()
                {
                        using (StringFormat sf = new StringFormat ((StringFormatFlags)Int32.MinValue)) {
@@ -104,9 +96,6 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void ctor_StringFormatFlags_Int32 ()
                {
                        using (StringFormat sf = new StringFormat ((StringFormatFlags) Int32.MinValue, Int32.MinValue)) {
@@ -129,15 +118,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                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)
@@ -167,15 +152,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void GenericTypographic_Local_Dispose ()
                {
                        StringFormat sf = StringFormat.GenericTypographic;
                        sf.Dispose (); // can't be cached
-                       CheckTypographic (sf);
+                       Assert.Throws<ArgumentException> (() => CheckTypographic (sf));
                }
 
                [Test]
@@ -190,14 +171,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void Alignment_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.Alignment = (StringAlignment) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.Alignment = (StringAlignment) Int32.MinValue);
                        }
                }
 
@@ -213,14 +190,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void HotkeyPrefix_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.HotkeyPrefix = (HotkeyPrefix) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.HotkeyPrefix = (HotkeyPrefix) Int32.MinValue);
                        }
                }
 
@@ -236,14 +209,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void LineAlignment_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.LineAlignment = (StringAlignment) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.LineAlignment = (StringAlignment) Int32.MinValue);
                        }
                }
 
@@ -259,14 +228,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidEnumArgumentException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void Trimming_Invalid ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.Trimming = (StringTrimming) Int32.MinValue;
+                               Assert.Throws<InvalidEnumArgumentException> (() => sf.Trimming = (StringTrimming) Int32.MinValue);
                        }
                }
 
@@ -281,9 +246,6 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void Clone_Complex ()
                {
                        using (StringFormat sf = new StringFormat ()) {
@@ -321,9 +283,6 @@ namespace MonoTests.System.Drawing{
                }               
                
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void TabsStops() 
                {
                        using (StringFormat smf = new StringFormat ()) {
@@ -344,21 +303,14 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void SetTabStops_Null ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.SetTabStops (Single.NaN, null);
+                               Assert.Throws<NullReferenceException> (() => sf.SetTabStops (Single.NaN, null));
                        }
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void SetDigitSubstitution ()
                {
                        using (StringFormat sf = new StringFormat ()) {
@@ -369,14 +321,10 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (NullReferenceException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void SetMeasurableCharacterRanges_Null ()
                {
                        using (StringFormat sf = new StringFormat ()) {
-                               sf.SetMeasurableCharacterRanges (null);
+                               Assert.Throws<NullReferenceException> (() => sf.SetMeasurableCharacterRanges (null));
                        }
                }
 
@@ -399,15 +347,11 @@ namespace MonoTests.System.Drawing{
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void SetMeasurableCharacterRanges_TooBig ()
                {
                        using (StringFormat sf = new StringFormat ()) {
                                CharacterRange[] range = new CharacterRange[33];
-                               sf.SetMeasurableCharacterRanges (range);
+                               Assert.Throws<OverflowException> (() => sf.SetMeasurableCharacterRanges (range));
                        }
                }
        }