Author: suresh
Date: 2005-05-04 05:21:36 -0400 (Wed, 04 May 2005)
New Revision: 44011

Modified:
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
   trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
   trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs
Log:
2005-05-04  Sureshkumar T  <[EMAIL PROTECTED]>
        * System.Data/DataRowCollection.cs: Clear : remove rows from indexes
        * Test/System.Data/DataTableTest.cs: Added a test for DataTable. Should 
clear rows
        from indexes as well. Simplified table creation for ClearReset test.



Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-04 08:56:29 UTC 
(rev 44010)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-04 09:21:36 UTC 
(rev 44011)
@@ -1,3 +1,7 @@
+2005-05-04  Sureshkumar T  <[EMAIL PROTECTED]>
+
+       * DataRowCollection.cs: Clear : remove rows from indexes
+
 2005-05-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XmlSchemaDataImporter.cs : XmlSchemaParicle might be XmlSchemaAny.

Modified: trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs        
2005-05-04 08:56:29 UTC (rev 44010)
+++ trunk/mcs/class/System.Data/System.Data/DataRowCollection.cs        
2005-05-04 09:21:36 UTC (rev 44011)
@@ -149,6 +149,10 @@
                                        }
                                }
                        }
+                        // Remove from indexes
+                        for (int i = 0; i < this.Count; i++)
+                                this.table.DeleteRowFromIndexes (this [i]);
+
                        List.Clear ();
                }
 

Modified: trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2005-05-04 
08:56:29 UTC (rev 44010)
+++ trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2005-05-04 
09:21:36 UTC (rev 44011)
@@ -1,3 +1,9 @@
+2005-05-04  Sureshkumar T  <[EMAIL PROTECTED]>
+
+       * DataTableTest.cs: Added a test for DataTable. Should clear rows
+       from indexes as well. Simplified table creation for ClearReset
+       test.
+
 2005-04-29  Sureshkumar T  <[EMAIL PROTECTED]>
 
        * DataTableReaderTest.cs: Added few more tests.

Modified: trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs       
2005-05-04 08:56:29 UTC (rev 44010)
+++ trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs       
2005-05-04 09:21:36 UTC (rev 44011)
@@ -1145,31 +1145,16 @@
                        DataSet set = new DataSet ();
                        set.Tables.Add (table);
                        set.Tables.Add (table1);
-                
-                       DataColumn col = new DataColumn ();
-                       col.ColumnName = "Id";
-                       col.DataType = Type.GetType ("System.Int32");
-                       table.Columns.Add (col);
-                       UniqueConstraint uc = new UniqueConstraint ("UK1", 
table.Columns[0] );
-                       table.Constraints.Add (uc);
-                       table.CaseSensitive = false;
-                
-                       col = new DataColumn ();
-                       col.ColumnName = "Name";
-                       col.DataType = Type.GetType ("System.String");
-                       table.Columns.Add (col);
-                
-                       col = new DataColumn ();
-                       col.ColumnName = "Id";
-                       col.DataType = Type.GetType ("System.Int32");
-                       table1.Columns.Add (col);
-                
-                       col = new DataColumn ();
-                       col.ColumnName = "Name";
-                       col.DataType = Type.GetType ("System.String");
-                       table1.Columns.Add (col);
 
-                       DataRelation dr = new DataRelation ("DR", 
table.Columns[0], table1.Columns[0]);
+                        table.Columns.Add ("Id", typeof (int));
+                        table.Columns.Add ("Name", typeof (string));
+                        table.Constraints.Add (new UniqueConstraint ("UK1", 
table.Columns [0]));
+                        table.CaseSensitive = false;
+                        
+                        table1.Columns.Add ("Id", typeof (int));
+                        table1.Columns.Add ("Name", typeof (string));
+
+                        DataRelation dr = new DataRelation ("DR", 
table.Columns[0], table1.Columns[0]);
                        set.Relations.Add (dr);
                 
                        DataRow row = table.NewRow ();
@@ -1194,13 +1179,13 @@
                        AssertEquals ("#CT02", 0, table.ChildRelations.Count);
                        AssertEquals ("#CT03", 0, table.ParentRelations.Count);
                        AssertEquals ("#CT04", 0, table.Constraints.Count);
-                       table.Clear ();
 
                        table1.Reset ();
                        AssertEquals ("#A05", 0, table1.Rows.Count);
                        AssertEquals ("#A06", 0, table1.Constraints.Count);
                        AssertEquals ("#A07", 0, table1.ParentRelations.Count);
                
+                        // clear test
                        table.Clear ();
                        AssertEquals ("#A08", 0, table.Rows.Count);
 #if NET_1_1
@@ -1209,8 +1194,36 @@
                        AssertEquals ("#A09", 1, table.Constraints.Count);
 #endif
                        AssertEquals ("#A10", 0, table.ChildRelations.Count);
+
                }
 
+                [Test]
+                public void ClearTest ()
+                {
+                        DataTable table = new DataTable ("test");
+                        table.Columns.Add ("id", typeof (int));
+                        table.Columns.Add ("name", typeof (string));
+                        
+                        table.PrimaryKey = new DataColumn [] { table.Columns 
[0] } ;
+                        
+                        table.Rows.Add (new object [] { 1, "mono 1" });
+                        table.Rows.Add (new object [] { 2, "mono 2" });
+                        table.Rows.Add (new object [] { 3, "mono 3" });
+                        table.Rows.Add (new object [] { 4, "mono 4" });
+
+                        table.AcceptChanges ();
+                        
+                        table.Clear ();
+                        
+                        DataRow r = table.Rows.Find (1);
+                        AssertEquals ("#1 should have cleared", true, r == 
null);
+
+                        // try adding new row. indexes should have cleared
+                        table.Rows.Add (new object [] { 2, "mono 2" });
+                        AssertEquals ("#2 should add row", 1, 
table.Rows.Count);
+                }
+                
+
                [Test]
                public void Serialize ()
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to