|
|
@@ -1,3 +1,28 @@
|
|
|
+//
|
|
|
+// ColorTranslator class testing unit
|
|
|
+//
|
|
|
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
|
|
|
+//
|
|
|
+// Permission is hereby granted, free of charge, to any person obtaining
|
|
|
+// a copy of this software and associated documentation files (the
|
|
|
+// "Software"), to deal in the Software without restriction, including
|
|
|
+// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
+// distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
+// permit persons to whom the Software is furnished to do so, subject to
|
|
|
+// the following conditions:
|
|
|
+//
|
|
|
+// The above copyright notice and this permission notice shall be
|
|
|
+// included in all copies or substantial portions of the Software.
|
|
|
+//
|
|
|
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
+//
|
|
|
+
|
|
|
using System;
|
|
|
using System.Drawing;
|
|
|
using System.Security.Permissions;
|
|
|
@@ -8,6 +33,59 @@ namespace MonoTests.System.Drawing {
|
|
|
[TestFixture]
|
|
|
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
|
|
|
public class ColorTranslatorFixture {
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FromHtml_Null ()
|
|
|
+ {
|
|
|
+ Assert.AreEqual (0, ColorTranslator.FromHtml (null).ToArgb ());
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FromHtml_Empty ()
|
|
|
+ {
|
|
|
+ Assert.AreEqual (0, ColorTranslator.FromHtml (String.Empty).ToArgb ());
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FromHtml_Int ()
|
|
|
+ {
|
|
|
+ Assert.AreEqual (-1, ColorTranslator.FromHtml ("-1").ToArgb (), "-1");
|
|
|
+ Assert.AreEqual (0, ColorTranslator.FromHtml ("0").ToArgb (), "0");
|
|
|
+ Assert.AreEqual (1, ColorTranslator.FromHtml ("1").ToArgb (), "1");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FromHtml_PoundInt ()
|
|
|
+ {
|
|
|
+ Assert.AreEqual (0, ColorTranslator.FromHtml ("#0").ToArgb (), "#0");
|
|
|
+ Assert.AreEqual (1, ColorTranslator.FromHtml ("#1").ToArgb (), "#1");
|
|
|
+ Assert.AreEqual (255, ColorTranslator.FromHtml ("#FF").ToArgb (), "#FF");
|
|
|
+ Assert.AreEqual (65535, ColorTranslator.FromHtml ("#FFFF").ToArgb (), "#FFFF");
|
|
|
+ Assert.AreEqual (-1, ColorTranslator.FromHtml ("#FFFFFF").ToArgb (), "#FFFFFF");
|
|
|
+ Assert.AreEqual (-1, ColorTranslator.FromHtml ("#FFFFFFFF").ToArgb (), "#FFFFFFFF");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ [ExpectedException (typeof (Exception))]
|
|
|
+ public void FromHtml_PoundNegative ()
|
|
|
+ {
|
|
|
+ ColorTranslator.FromHtml ("#-1");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ [ExpectedException (typeof (Exception))]
|
|
|
+ public void FromHtml_PoundTooLarge ()
|
|
|
+ {
|
|
|
+ ColorTranslator.FromHtml ("#100000000");
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ [ExpectedException (typeof (Exception))]
|
|
|
+ public void FromHtml_Unkown ()
|
|
|
+ {
|
|
|
+ ColorTranslator.FromHtml ("unknown-color-test");
|
|
|
+ }
|
|
|
+
|
|
|
[Test]
|
|
|
public void FromHtml ()
|
|
|
{
|