* corlib_test.dll.sources: added ReadOnlyCollectionTest.cs.
authorGert Driesen <drieseng@users.sourceforge.net>
Sun, 13 Jan 2008 18:51:59 +0000 (18:51 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Sun, 13 Jan 2008 18:51:59 +0000 (18:51 -0000)
* CollectionTest.cs: Added test for ICollection.CopyTo.
* ReadOnlyCollectionTest.cs: Added ctor tests, and test for
ICollection.CopyTo.

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

mcs/class/corlib/ChangeLog
mcs/class/corlib/Test/System.Collections.ObjectModel/ChangeLog
mcs/class/corlib/Test/System.Collections.ObjectModel/CollectionTest.cs
mcs/class/corlib/Test/System.Collections.ObjectModel/ReadOnlyCollectionTest.cs [new file with mode: 0644]
mcs/class/corlib/corlib_test.dll.sources

index 85e911127545a480f1714bb2e0ba284465ceaf88..5f11aa00b26a9ebf21772f1e45b95671dc5d9c5e 100644 (file)
@@ -1,3 +1,7 @@
+2008-01-13  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * corlib_test.dll.sources: added ReadOnlyCollectionTest.cs.
+
 2007-12-31  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * corlib_test.dll.sources: added Consts.cs.
index 2ff9606811691052289cc4a2b094d2edce7741bd..392cca664598b5bed857ad7a355b1d647e128994 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-13  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * CollectionTest.cs: Added test for ICollection.CopyTo.
+       * ReadOnlyCollectionTest.cs: Added ctor tests, and test for
+       ICollection.CopyTo.
+
 2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
 
        * KeyedCollectionTest.cs : new file by Carlo Kok (ck@carlo-kok.com).
index a69e50cbd7142302471a635ee231b4367eb29537..170abc41fff89a8d3ac61dea5850508cedc57c0b 100644 (file)
@@ -64,6 +64,36 @@ namespace MonoTests.System.Collections.ObjectModel
                        Assert.IsTrue (cLock.GetType ().Equals (typeof (object)));
                }
 
+               [Test]
+               [Category ("NotWorking")]
+               public void ICollection_CopyTo ()
+               {
+                       Collection <int> c = new Collection <int> ();
+                       c.Add (10);
+                       c.Add (7);
+
+                       Array array = Array.CreateInstance (typeof (int), 2);
+                       ((ICollection) c).CopyTo (array, 0);
+                       Assert.AreEqual (10, array.GetValue (0), "#A1");
+                       Assert.AreEqual (7, array.GetValue (1), "#A2");
+
+                       array = Array.CreateInstance (typeof (int), 5);
+                       ((ICollection) c).CopyTo (array, 2);
+                       Assert.AreEqual (0, array.GetValue (0), "#B1");
+                       Assert.AreEqual (0, array.GetValue (1), "#B2");
+                       Assert.AreEqual (10, array.GetValue (2), "#B3");
+                       Assert.AreEqual (7, array.GetValue (3), "#B4");
+                       Assert.AreEqual (0, array.GetValue (4), "#B5");
+
+                       array = Array.CreateInstance (typeof (object), 5);
+                       ((ICollection) c).CopyTo (array, 2);
+                       Assert.IsNull (array.GetValue (0), "#C1");
+                       Assert.IsNull (array.GetValue (1), "#C2");
+                       Assert.AreEqual (10, array.GetValue (2), "#C3");
+                       Assert.AreEqual (7, array.GetValue (3), "#C4");
+                       Assert.IsNull (array.GetValue (4), "#C2");
+               }
+
                class UnimplementedList <T> : IList <T>
                {
 
diff --git a/mcs/class/corlib/Test/System.Collections.ObjectModel/ReadOnlyCollectionTest.cs b/mcs/class/corlib/Test/System.Collections.ObjectModel/ReadOnlyCollectionTest.cs
new file mode 100644 (file)
index 0000000..16ccf95
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// MonoTests.System.Collections.Generic.Test.ReadOnlyCollectionTest
+//
+// Authors:
+//     Gert Driesen (drieseng@users.sourceforge.net)
+//
+// Copyright (C) 2008 Gert Driesen
+//
+// 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.
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Collections.ObjectModel
+{
+       [TestFixture]
+       public class ReadOnlyCollectionTest
+       {
+               [Test]
+               public void Constructor0 ()
+               {
+                       Collection <int> c = new Collection <int> ();
+                       c.Add (10);
+                       c.Add (7);
+
+                       ReadOnlyCollection <int> r = new ReadOnlyCollection <int> (c);
+                       Assert.AreEqual (10, r [0], "#1");
+                       Assert.AreEqual (7, r [1], "#2");
+               }
+
+               [Test]
+               public void Constructor0_List_Null ()
+               {
+                       try {
+                               new ReadOnlyCollection <int> ((List <int>) null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("list", ex.ParamName, "#6");
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ICollection_CopyTo ()
+               {
+                       Collection <int> c = new Collection <int> ();
+                       c.Add (10);
+                       c.Add (7);
+
+                       ReadOnlyCollection <int> r = new ReadOnlyCollection <int> (c);
+                       Array array = Array.CreateInstance (typeof (int), 2);
+                       ((ICollection) c).CopyTo (array, 0);
+                       Assert.AreEqual (10, array.GetValue (0), "#A1");
+                       Assert.AreEqual (7, array.GetValue (1), "#A2");
+
+                       array = Array.CreateInstance (typeof (object), 2);
+                       ((ICollection) c).CopyTo (array, 0);
+                       Assert.AreEqual (10, array.GetValue (0), "#B1");
+                       Assert.AreEqual (7, array.GetValue (1), "#B2");
+               }
+       }
+}
+
+#endif
index fe2d6273e21332248d46f026d3f03fb6b5ce33bb..8cf28eea27078845357d6fd2a14dde3f9bece7c8 100644 (file)
@@ -40,6 +40,7 @@ System.Collections.Generic/IListTest.cs
 System.Collections.Generic/ListTest.cs
 System.Collections.ObjectModel/CollectionTest.cs
 System.Collections.ObjectModel/KeyedCollectionTest.cs
+System.Collections.ObjectModel/ReadOnlyCollectionTest.cs
 System/ConsoleTest.cs
 System/ConvertTest.cs
 System/DateTimeOffsetTest.cs