Remove invalid tests for image palettes in GdiPlusTest (#5671)
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / ColorConverter.cs
index df03570ef0a9cb3e69e2115d86ff59e1ba4360ee..b73ed00255cff0e05e66c36cffab2440d60c577e 100644 (file)
@@ -36,9 +36,8 @@ using NUnit.Framework;
 namespace MonoTests.System.Drawing {
 
        [TestFixture]
-       [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
-       public class ColorConverterFixture
-       {
+       public class ColorConverterTest {
+
                Color col;
                Color colnamed;
                ColorConverter colconv;
@@ -59,9 +58,6 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void CanConvertFrom () {
                        Assert.IsTrue (colconv.CanConvertFrom (typeof (String)), "CCF#1");
                        Assert.IsTrue (colconv.CanConvertFrom (null, typeof (String)), "CCF#1a");
@@ -92,9 +88,6 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void ConvertFrom ()
                {
                        Color color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
@@ -156,13 +149,8 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (Color.Empty, colconv.ConvertFrom (" "), "CF#4");
                        Assert.AreEqual (Color.Red, colconv.ConvertFrom ("Red"), "CF#5");
                        Assert.AreEqual (Color.Red, colconv.ConvertFrom (" Red "), "CF#6");
-               }
 
-               [Test]
-               [NUnit.Framework.Category ("NotWorking")]
-               public void ConvertFrom_NotWorking ()
-               {
-                       Color color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+                       color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
                                "0x123");
                        Assert.AreEqual (0, color.A, "CF8#1");
                        Assert.AreEqual (0, color.R, "CF8#2");
@@ -178,75 +166,73 @@ 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))]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                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]
+               public void ConvertFrom_CultureNull ()
+               {
+                       Color color = (Color) colconv.ConvertFrom (null, null, "#0x23190A44");
+                       Assert.AreEqual (35, color.A, "A");
+                       Assert.AreEqual (25, color.R, "R");
+                       Assert.AreEqual (10, color.G, "G");
+                       Assert.AreEqual (68, color.B, "B");
                }
 
                [Test]
@@ -268,43 +254,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]
@@ -355,16 +336,12 @@ 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]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void ConvertFromInvariantString_InvalidNumber ()
                {
                        try {
@@ -385,18 +362,14 @@ 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]
-#if TARGET_JVM
-               [NUnit.Framework.Category ("NotWorking")]
-#endif
                public void ConvertFromString_InvalidNumber ()
                {
                        try {
@@ -428,13 +401,8 @@ namespace MonoTests.System.Drawing {
 
                [Test]
                public void GetStandardValues () {
-#if NET_2_0
                        Assert.AreEqual ((int)KnownColor.MenuHighlight, colconv.GetStandardValues ().Count);
                        Assert.AreEqual ((int)KnownColor.MenuHighlight, colconv.GetStandardValues (null).Count);                        
-#else
-                       Assert.AreEqual ((int)KnownColor.YellowGreen, colconv.GetStandardValues ().Count);
-                       Assert.AreEqual ((int)KnownColor.YellowGreen, colconv.GetStandardValues (null).Count);  
-#endif
                }
 
                [Test]
@@ -443,10 +411,9 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [ExpectedException (typeof (Exception))]
                public void ConvertFromString_FromHtml_PoundTooLarge ()
                {
-                       colconv.ConvertFromString ("#100000000");
+                       Assert.Throws<Exception> (() => colconv.ConvertFromString ("#100000000"));
                }
        }
 }