Browse Source

* ColorConverter.cs: Merged tests from TestColorConverter.cs. Fixed
tests using current culture.
* TestColorConverter.cs: Merged tests with ColorConverter.cs and
removed.
* System.Drawing.dll.sources: Removed TestColorConverter again, as
there was already a test class for ColorConverter.
* ColorConverter.cs: Use TextInfo.ListSeparator as separator, as this
appears to be what MS.NET uses.

svn path=/trunk/mcs/; revision=48374

Gert Driesen 20 years ago
parent
commit
7667343f6b

+ 6 - 1
mcs/class/System.Drawing/ChangeLog

@@ -1,4 +1,9 @@
-2005-08-14 Gert Driesen <drieseng#users.sourceforge.net>
+2005-08-14 Gert Driesen <[email protected]>
+	
+	* System.Drawing.dll.sources: Removed TestColorConverter again, as 
+	there was already a test class for ColorConverter.
+
+2005-08-14 Gert Driesen <[email protected]>
 
 	* System.Drawing.dll.sources: Added TestColorConverter.cs.
 

+ 5 - 0
mcs/class/System.Drawing/System.Drawing/ChangeLog

@@ -1,3 +1,8 @@
+2005-08-14 Gert Driesen <[email protected]>
+
+	* ColorConverter.cs: Use TextInfo.ListSeparator as separator, as this
+	appears to be what MS.NET uses.
+
 2005-08-14 Gert Driesen <[email protected]>
 
 	* Point.cs: Use invariant culture for converting numbers to string.

+ 14 - 4
mcs/class/System.Drawing/System.Drawing/ColorConverter.cs

@@ -87,7 +87,7 @@ namespace System.Drawing
 			if (named != null)
 				return (Color) named;
 
-			String numSeparator = culture.NumberFormat.NumberGroupSeparator;
+			String numSeparator = culture.TextInfo.ListSeparator;
 
 			int A, R, G, B;
 			if (s.IndexOf (numSeparator) > 0) { // "A, R, G, B" format
@@ -151,12 +151,22 @@ namespace System.Drawing
 				if (color.IsNamedColor)
 					return color.Name;
 
+				String numSeparator = culture.TextInfo.ListSeparator;
+
 				StringBuilder sb = new StringBuilder ();
 				if (color.A != 255) {
-					sb.Append (color.A); sb.Append (", ");
+					sb.Append (color.A);
+					sb.Append (numSeparator);
+					sb.Append (" ");
 				}
-				sb.Append (color.R); sb.Append (", ");
-				sb.Append (color.G); sb.Append (", ");
+				sb.Append (color.R);
+				sb.Append (numSeparator);
+				sb.Append (" ");
+
+				sb.Append (color.G);
+				sb.Append (numSeparator);
+				sb.Append (" ");
+
 				sb.Append (color.B);
 				return sb.ToString ();
 			}

+ 0 - 1
mcs/class/System.Drawing/System.Drawing_test.dll.sources

@@ -3,7 +3,6 @@ System.Drawing/ColorConverter.cs
 System.Drawing/TestBitmap.cs
 System.Drawing/TestBrushes.cs
 System.Drawing/TestColor.cs
-System.Drawing/TestColorConverter.cs
 System.Drawing/TestFont.cs
 System.Drawing/TestPens.cs
 System.Drawing/TestPoint.cs

+ 7 - 0
mcs/class/System.Drawing/Test/System.Drawing/ChangeLog

@@ -1,3 +1,10 @@
+2005-08-14  Gert Driesen  <[email protected]>
+
+	* ColorConverter.cs: Merged tests from TestColorConverter.cs. Fixed
+	tests using current culture.
+	* TestColorConverter.cs: Merged tests with ColorConverter.cs and 
+	removed.
+
 2005-08-14  Gert Driesen  <[email protected]>
 
 	* TestColor.cs: Added test for ToString() on uninitialized color.

+ 89 - 75
mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs

@@ -1,26 +1,29 @@
 using System;
-using System.Drawing;
-using NUnit.Framework;
+using System.Collections;
 using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
 using System.Globalization;
-using System.Collections;
 
+using NUnit.Framework;
 
 namespace MonoTests.System.Drawing {
 
-	[TestFixture]	
+	[TestFixture]
 	public class ColorConverterFixture
 	{
 		Color col;
 		Color colnamed;
 		ColorConverter colconv;
 		String colStr;
+		String colStrInvariant;
 		String colnamedStr;
 
 		[SetUp]
 		public void SetUp () {
 			col = Color.FromArgb (10, 20, 30);
-			colStr = "10, 20, 30";
+			colStr = string.Format ("10{0} 20{0} 30", CultureInfo.CurrentCulture.TextInfo.ListSeparator);
+			colStrInvariant = string.Format ("10{0} 20{0} 30", CultureInfo.InvariantCulture.TextInfo.ListSeparator);
 
 			colnamed = Color.ForestGreen;
 			colnamedStr = "ForestGreen";
@@ -54,15 +57,21 @@ namespace MonoTests.System.Drawing {
 			Assert.IsTrue (! colconv.CanConvertTo (null, typeof (SizeF)), "CCT#7");
 			Assert.IsTrue (! colconv.CanConvertTo (null, typeof (Object)), "CCT#8");
 			Assert.IsTrue (! colconv.CanConvertTo (null, typeof (int)), "CCT#9");
+			Assert.IsTrue (colconv.CanConvertTo (typeof (InstanceDescriptor)), "CCT#10");
 		}
 
 		[Test]
 		public void ConvertFrom ()
 		{
 			Assert.AreEqual (col, (Color) colconv.ConvertFrom (null,
-				CultureInfo.InvariantCulture, "10, 20, 30"), "CF#1");
+				CultureInfo.InvariantCulture, colStrInvariant), "CF#1");
 			Assert.AreEqual (colnamed, (Color) colconv.ConvertFrom (null,
-				CultureInfo.InvariantCulture, "ForestGreen"), "CF#2");
+				CultureInfo.InvariantCulture, colnamedStr), "CF#2");
+
+			Assert.AreEqual (Color.Empty, colconv.ConvertFrom (string.Empty), "CF#3");
+			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]
@@ -157,14 +166,19 @@ namespace MonoTests.System.Drawing {
 		[Test]
 		public void ConvertTo ()
 		{
-			Assert.AreEqual ("10, 20, 30", colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+			Assert.AreEqual (colStrInvariant, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
 				Color.FromArgb (10, 20, 30), typeof (String)), "CT#1");
-			Assert.AreEqual ("10, 20, 30", colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+			Assert.AreEqual (colStrInvariant, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
 				Color.FromArgb (255, 10, 20, 30), typeof (String)), "CT#2");
 			Assert.AreEqual ("10, 20, 30, 40", colconv.ConvertTo (null, CultureInfo.InvariantCulture,
 				Color.FromArgb (10, 20, 30, 40), typeof (String)), "CT#3");
 			Assert.AreEqual (colnamedStr, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
 				colnamed, typeof (String)), "CT#4");
+
+			Assert.AreEqual (string.Empty, colconv.ConvertTo (Color.Empty, typeof (string)), "CT#5");
+			Assert.AreEqual ("Red", colconv.ConvertTo (Color.Red, typeof (string)), "CT#6");
+			Assert.AreEqual (string.Empty, colconv.ConvertTo (null, typeof (string)), "CT#7");
+			Assert.AreEqual ("test", colconv.ConvertTo ("test", typeof (string)), "CT#8");
 		}
 
 		[Test]
@@ -246,72 +260,72 @@ namespace MonoTests.System.Drawing {
 			attrs = Attribute.GetCustomAttributes (typeof (Color), true);
 			Assert.AreEqual (null, colconv.GetProperties (null, col, attrs), "GP3#5");
 		}
-
-		[Test]
-		public void ConvertFromInvariantString_string () {
-			Assert.AreEqual (col, colconv.ConvertFromInvariantString (colStr), "CFISS#1");
-			Assert.AreEqual (colnamed, colconv.ConvertFromInvariantString (colnamedStr), "CFISS#2");
-		}
-
-		[Test]
-		[ExpectedException (typeof (ArgumentException))]
-		public void ConvertFromInvariantString_string_exc_1 () {
-			colconv.ConvertFromInvariantString ("1, 2, 3, 4, 5");
-		}
-
-		[Test]
-		[NUnit.Framework.Category ("NotDotNet")]
-		[ExpectedException (typeof (ArgumentException))]
-		public void ConvertFromInvariantString_string_exc_2 () {
-			colconv.ConvertFromInvariantString ("hello");
-		}
-
-		[Test]
-		public void ConvertFromString_string () {
-			Assert.AreEqual (col, colconv.ConvertFromString (colStr), "CFSS#1");
-			Assert.AreEqual (colnamed, colconv.ConvertFromString (colnamedStr), "CFSS#2");
-		}
-
-		[Test]
-		[ExpectedException (typeof (ArgumentException))]
-		public void ConvertFromString_string_exc_1 () {
-			colconv.ConvertFromString ("1, 2, 3, 4, 5");
-		}
-
-		[Test]
-		[NUnit.Framework.Category ("NotDotNet")]
-		[ExpectedException (typeof (ArgumentException))]
-		public void ConvertFromString_string_exc_2 () {
-			colconv.ConvertFromString ("hello");
-		}
-
-		[Test]
-		public void ConvertToInvariantString_string () {
-			Assert.AreEqual (colStr, colconv.ConvertToInvariantString (col), "CFISS#1");
-			Assert.AreEqual (colnamedStr, colconv.ConvertToInvariantString (colnamed), "CFISS#2");
-		}
-
-		[Test]
-		public void ConvertToString_string () {
-			Assert.AreEqual (colStr, colconv.ConvertToString (col), "CFISS#1");
-			Assert.AreEqual (colnamedStr, colconv.ConvertToString (colnamed), "CFISS#2");
-		}
-
-		[Test]
-		public void GetStandardValuesSupported () {
-			Assert.IsTrue (colconv.GetStandardValuesSupported ());
-		}
-
-		[Test]
-		public void GetStandardValues () {
-			Assert.AreEqual (167, colconv.GetStandardValues ().Count);
-			Assert.AreEqual (167, colconv.GetStandardValues (null).Count);
-		}
-
-		[Test]
-		public void GetStandardValuesExclusive () {
-			Assert.AreEqual (false, colconv.GetStandardValuesExclusive ());
-		}
+
+		[Test]
+		public void ConvertFromInvariantString_string () {
+			Assert.AreEqual (col, colconv.ConvertFromInvariantString (colStrInvariant), "CFISS#1");
+			Assert.AreEqual (colnamed, colconv.ConvertFromInvariantString (colnamedStr), "CFISS#2");
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConvertFromInvariantString_string_exc_1 () {
+			colconv.ConvertFromInvariantString ("1, 2, 3, 4, 5");
+		}
+
+		[Test]
+		[NUnit.Framework.Category ("NotDotNet")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConvertFromInvariantString_string_exc_2 () {
+			colconv.ConvertFromInvariantString ("hello");
+		}
+
+		[Test]
+		public void ConvertFromString_string () {
+			Assert.AreEqual (col, colconv.ConvertFromString (colStr), "CFSS#1");
+			Assert.AreEqual (colnamed, colconv.ConvertFromString (colnamedStr), "CFSS#2");
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConvertFromString_string_exc_1 () {
+			colconv.ConvertFromString ("1, 2, 3, 4, 5");
+		}
+
+		[Test]
+		[NUnit.Framework.Category ("NotDotNet")]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConvertFromString_string_exc_2 () {
+			colconv.ConvertFromString ("hello");
+		}
+
+		[Test]
+		public void ConvertToInvariantString_string () {
+			Assert.AreEqual (colStrInvariant, colconv.ConvertToInvariantString (col), "CFISS#1");
+			Assert.AreEqual (colnamedStr, colconv.ConvertToInvariantString (colnamed), "CFISS#2");
+		}
+
+		[Test]
+		public void ConvertToString_string () {
+			Assert.AreEqual (colStr, colconv.ConvertToString (col), "CFISS#1");
+			Assert.AreEqual (colnamedStr, colconv.ConvertToString (colnamed), "CFISS#2");
+		}
+
+		[Test]
+		public void GetStandardValuesSupported () {
+			Assert.IsTrue (colconv.GetStandardValuesSupported ());
+		}
+
+		[Test]
+		public void GetStandardValues () {
+			Assert.AreEqual (167, colconv.GetStandardValues ().Count);
+			Assert.AreEqual (167, colconv.GetStandardValues (null).Count);
+		}
+
+		[Test]
+		public void GetStandardValuesExclusive () {
+			Assert.AreEqual (false, colconv.GetStandardValuesExclusive ());
+		}
 
 	}
 }

+ 0 - 79
mcs/class/System.Drawing/Test/System.Drawing/TestColorConverter.cs

@@ -1,79 +0,0 @@
-//
-// Tests for System.Drawing.ColorConverter.cs 
-//
-// Author:
-//	Gert Driesen ([email protected])
-//
-
-//
-// Copyright (C) 2004 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.ComponentModel.Design.Serialization;
-
-using NUnit.Framework;
-
-namespace MonoTests.System.Drawing
-{
-	[TestFixture]
-	public class ColorConverterTest
-	{
-		private ColorConverter converter = new ColorConverter();
-
-		[Test]
-		public void TestCanConvertFrom ()
-		{
-			Assert.IsTrue (converter.CanConvertFrom (typeof (string)), "#1");
-			Assert.IsFalse (converter.CanConvertFrom (typeof (Object)), "#2");
-			Assert.IsFalse (converter.CanConvertFrom (typeof (int)), "#3");
-		}
-
-		[Test]
-		public void TestCanConvertTo ()
-		{
-			Assert.IsTrue (converter.CanConvertTo (typeof (string)), "#1");
-			Assert.IsFalse (converter.CanConvertTo (typeof (Object)), "#2");
-			Assert.IsFalse (converter.CanConvertTo (typeof (int)), "#3");
-			Assert.IsTrue (converter.CanConvertTo (typeof (InstanceDescriptor)), "#4");
-		}
-
-		[Test]
-		public void TestConvertFrom ()
-		{
-			Assert.AreEqual (Color.Empty, converter.ConvertFrom (string.Empty), "#1");
-			Assert.AreEqual (Color.Empty, converter.ConvertFrom (" "), "#2");
-			Assert.AreEqual (Color.Red, converter.ConvertFrom ("Red"), "#3");
-			Assert.AreEqual (Color.Red, converter.ConvertFrom (" Red "), "#4");
-		}
-
-		[Test]
-		public void TestConvertTo ()
-		{
-			Assert.AreEqual (string.Empty, converter.ConvertTo (Color.Empty, typeof (string)), "#1");
-			Assert.AreEqual ("Red", converter.ConvertTo (Color.Red, typeof(string)), "#2");
-			Assert.AreEqual (string.Empty, converter.ConvertTo (null, typeof (string)), "#3");
-			Assert.AreEqual ("test", converter.ConvertTo ("test", typeof (string)), "#4");
-		}
-	}
-}