Author: gert
Date: 2006-11-08 14:53:28 -0500 (Wed, 08 Nov 2006)
New Revision: 67548
Added:
trunk/mcs/class/System/Test/System.ComponentModel/ArrayConverterTests.cs
Modified:
trunk/mcs/class/System/ChangeLog
trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
trunk/mcs/class/System/System.ComponentModel/ChangeLog
trunk/mcs/class/System/System_test.dll.sources
trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
Log:
* System_test.dll.sources: Added ArrayConverterTests.cs.
* ArrayConverter.cs: Modifed ConvertTo for Array => String to match
MS. In GetProperties, throw NRE to match MS.
* ArrayConverterTests.cs: Added tests for ArrayConverter.
Modified: trunk/mcs/class/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/ChangeLog 2006-11-08 19:53:10 UTC (rev 67547)
+++ trunk/mcs/class/System/ChangeLog 2006-11-08 19:53:28 UTC (rev 67548)
@@ -1,3 +1,7 @@
+2006-11-08 Gert Driesen <[EMAIL PROTECTED]>
+
+ * System_test.dll.sources: Added ArrayConverterTests.cs.
+
2006-11-07 Andrew Skiba <[EMAIL PROTECTED]>
* System.Security.AccessControl/SemaphoreAuditRule.cs,
Modified: trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
2006-11-08 19:53:10 UTC (rev 67547)
+++ trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
2006-11-08 19:53:28 UTC (rev 67548)
@@ -43,7 +43,7 @@
throw new ArgumentNullException
("destinationType");
if (destinationType == typeof (string) && (value is
Array))
- return "(Array)";
+ return value.GetType ().Name + " Array";
return base.ConvertTo (context, culture, value,
destinationType);
}
@@ -51,6 +51,9 @@
public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context,
object value, Attribute[] attributes)
{
+ if (value == null)
+ throw new NullReferenceException ();
+
PropertyDescriptorCollection col = new
PropertyDescriptorCollection (null);
if (value is Array) {
Array array = (Array)value;
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2006-11-08
19:53:10 UTC (rev 67547)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2006-11-08
19:53:28 UTC (rev 67548)
@@ -1,3 +1,8 @@
+2006-11-08 Gert Driesen <[EMAIL PROTECTED]>
+
+ * ArrayConverter.cs: Modifed ConvertTo for Array => String to match
+ MS. In GetProperties, throw NRE to match MS.
+
2006-11-08 Chris Toshok <[EMAIL PROTECTED]>
* ArrayConverter.cs: implement GetProperties correctly, by
Modified: trunk/mcs/class/System/System_test.dll.sources
===================================================================
--- trunk/mcs/class/System/System_test.dll.sources 2006-11-08 19:53:10 UTC
(rev 67547)
+++ trunk/mcs/class/System/System_test.dll.sources 2006-11-08 19:53:28 UTC
(rev 67548)
@@ -105,6 +105,7 @@
System.Collections.Specialized/OrderedDictionaryTest.cs
System.Collections.Specialized/StringCollectionTest.cs
System.Collections.Specialized/StringDictionaryTest.cs
+System.ComponentModel/ArrayConverterTests.cs
System.ComponentModel/ByteConverterTests.cs
System.ComponentModel/CollectionConverterTest.cs
System.ComponentModel/ContainerTest.cs
Added: trunk/mcs/class/System/Test/System.ComponentModel/ArrayConverterTests.cs
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ArrayConverterTests.cs
2006-11-08 19:53:10 UTC (rev 67547)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ArrayConverterTests.cs
2006-11-08 19:53:28 UTC (rev 67548)
@@ -0,0 +1,101 @@
+//
+// System.ComponentModel.ArrayConverter test cases
+//
+// Authors:
+// Gert Driesen ([EMAIL PROTECTED])
+//
+// (c) 2006 Gert Driesen
+//
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ComponentModel
+{
+ [TestFixture]
+ public class ArrayConverterTests
+ {
+ private ArrayConverter converter;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ converter = new ArrayConverter ();
+ }
+
+ [Test]
+ public void ConvertTo ()
+ {
+ int [] numbers = new int [] { 5, 7 };
+ string text = (string) converter.ConvertTo (null,
CultureInfo.InvariantCulture,
+ numbers, typeof (string));
+ Assert.AreEqual ("Int32[] Array", text);
+ }
+
+ [Test]
+ public void ConvertTo_DestinationType_Null ()
+ {
+ int[] numbers = new int[] { 5, 7 };
+
+ try {
+ converter.ConvertTo (null,
CultureInfo.InvariantCulture,
+ numbers, (Type) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual ("destinationType",
ex.ParamName, "#2");
+ }
+ }
+
+ [Test]
+ public void GetProperties ()
+ {
+ int [] numbers = new int [] { 5, 7 };
+ PropertyDescriptorCollection pds =
converter.GetProperties (null,
+ numbers, null);
+ Assert.IsNotNull (pds, "#A1");
+ Assert.AreEqual (2, pds.Count, "#A2");
+
+ PropertyDescriptor pd = pds [0];
+ Assert.AreEqual (numbers.GetType (), pd.ComponentType,
"#B1");
+ Assert.AreEqual (false, pd.IsReadOnly, "#B2");
+ Assert.AreEqual ("[0]", pd.Name, "#B3");
+ Assert.AreEqual (typeof (int), pd.PropertyType, "#B4");
+ Assert.IsFalse (pd.CanResetValue (numbers), "#B5");
+ Assert.AreEqual (5, pd.GetValue (numbers), "#B6");
+ pd.SetValue (numbers, 9);
+ Assert.AreEqual (9, pd.GetValue (numbers), "#B7");
+ pd.ResetValue (numbers);
+ Assert.AreEqual (9, pd.GetValue (numbers), "#B8");
+ Assert.IsFalse (pd.ShouldSerializeValue (numbers),
"#B9");
+
+ pd = pds [1];
+ Assert.AreEqual (numbers.GetType (), pd.ComponentType,
"#C1");
+ Assert.AreEqual (false, pd.IsReadOnly, "#C2");
+ Assert.AreEqual ("[1]", pd.Name, "#C3");
+ Assert.AreEqual (typeof (int), pd.PropertyType, "#C4");
+ Assert.IsFalse (pd.CanResetValue (numbers), "#C5");
+ Assert.AreEqual (7, pd.GetValue (numbers), "#C6");
+ pd.SetValue (numbers, 3);
+ Assert.AreEqual (3, pd.GetValue (numbers), "#C7");
+ pd.ResetValue (numbers);
+ Assert.AreEqual (3, pd.GetValue (numbers), "#C8");
+ Assert.IsFalse (pd.ShouldSerializeValue (numbers),
"#C9");
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void GetProperties_Value_Null ()
+ {
+ converter.GetProperties (null, null, null);
+ }
+
+ [Test]
+ public void GetPropertiesSupported ()
+ {
+ Assert.IsTrue (converter.GetPropertiesSupported (null));
+ }
+ }
+}
Property changes on:
trunk/mcs/class/System/Test/System.ComponentModel/ArrayConverterTests.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2006-11-08
19:53:10 UTC (rev 67547)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2006-11-08
19:53:28 UTC (rev 67548)
@@ -1,3 +1,7 @@
+2006-11-08 Gert Driesen <[EMAIL PROTECTED]>
+
+ * ArrayConverterTests.cs: Added tests for ArrayConverter.
+
2006-11-07 Sebastien Pouliot <[EMAIL PROTECTED]>
* CollectionConverterTest.cs: New. Some unit tests done while tracking
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches