namespace MonoTests.System.Drawing {
[TestFixture]
- [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
- public class ColorConverterFixture
- {
+ public class ColorConverterTest {
+
Color col;
Color colnamed;
ColorConverter colconv;
}
[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");
}
[Test]
-#if TARGET_JVM
- [NUnit.Framework.Category ("NotWorking")]
-#endif
public void ConvertFrom ()
{
Color color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
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");
}
[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]
}
[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]
}
[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 {
}
[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 {
[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]
}
[Test]
- [ExpectedException (typeof (Exception))]
public void ConvertFromString_FromHtml_PoundTooLarge ()
{
- colconv.ConvertFromString ("#100000000");
+ Assert.Throws<Exception> (() => colconv.ConvertFromString ("#100000000"));
}
}
}