Author: toshok
Date: 2006-12-07 17:39:54 -0500 (Thu, 07 Dec 2006)
New Revision: 69211

Modified:
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataView.cs
   trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
   trunk/mcs/class/System.Data/Test/System.Data/DataViewTest.cs
Log:
In Test/System.Data:
2006-12-07  Chris Toshok  <[EMAIL PROTECTED]>

        * DataViewTest.cs: add unit test for parent/child relation
        changes.

In System.Data:
2006-12-07  Chris Toshok  <[EMAIL PROTECTED]>

        * DataView.cs: add CollectionChangeEventHandler's on the
        ChildRelations and ParentRelations collections, and emit
        ListChanged events with PropertyDescriptor.Added/Deleted/Changed
        in response.



Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog   2006-12-07 22:36:39 UTC 
(rev 69210)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog   2006-12-07 22:39:54 UTC 
(rev 69211)
@@ -1,3 +1,10 @@
+2006-12-07  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * DataView.cs: add CollectionChangeEventHandler's on the
+       ChildRelations and ParentRelations collections, and emit
+       ListChanged events with PropertyDescriptor.Added/Deleted/Changed
+       in response.
+
 2006-12-07  Nagappan A  <[EMAIL PROTECTED]>
 
        * DataTable.cs (ReadXml): Integrated the implementation of

Modified: trunk/mcs/class/System.Data/System.Data/DataView.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataView.cs 2006-12-07 22:36:39 UTC 
(rev 69210)
+++ trunk/mcs/class/System.Data/System.Data/DataView.cs 2006-12-07 22:39:54 UTC 
(rev 69211)
@@ -688,6 +688,8 @@
                        dataTable.RowDeleted     += new 
DataRowChangeEventHandler(OnRowDeleted);
                        dataTable.Columns.CollectionChanged += new 
CollectionChangeEventHandler(ColumnCollectionChanged);
                        dataTable.Constraints.CollectionChanged += new 
CollectionChangeEventHandler(OnConstraintCollectionChanged);
+                       dataTable.ChildRelations.CollectionChanged += new 
CollectionChangeEventHandler(OnRelationCollectionChanged);
+                       dataTable.ParentRelations.CollectionChanged += new 
CollectionChangeEventHandler(OnRelationCollectionChanged);
 
                        dataTable.Rows.ListChanged += new 
ListChangedEventHandler (OnRowCollectionChanged);
                }
@@ -710,6 +712,8 @@
                        dataTable.RowDeleted     -= new 
DataRowChangeEventHandler(OnRowDeleted);
                        dataTable.Columns.CollectionChanged -= new 
CollectionChangeEventHandler(ColumnCollectionChanged);
                        dataTable.Constraints.CollectionChanged -= new 
CollectionChangeEventHandler(OnConstraintCollectionChanged);
+                       dataTable.ChildRelations.CollectionChanged -= new 
CollectionChangeEventHandler(OnRelationCollectionChanged);
+                       dataTable.ParentRelations.CollectionChanged -= new 
CollectionChangeEventHandler(OnRelationCollectionChanged);
 
                        dataTable.Rows.ListChanged -= new 
ListChangedEventHandler (OnRowCollectionChanged);
                }
@@ -783,6 +787,7 @@
                        if (args.Action == CollectionChangeAction.Refresh)
                                OnListChanged (new ListChangedEventArgs 
(ListChangedType.PropertyDescriptorChanged,0,0));
                }
+
                private void OnConstraintCollectionChanged(object sender, 
CollectionChangeEventArgs args)
                {
                        //      The Sort variable is set to the 
UniqueConstraint column.
@@ -799,6 +804,19 @@
                        // UpdateIndex() is not invoked here.
                }
 
+               private void OnRelationCollectionChanged(object sender, 
CollectionChangeEventArgs args)
+               {
+                       /* PropertyDescriptor Add */
+                       if (args.Action == CollectionChangeAction.Add)
+                               OnListChanged (new ListChangedEventArgs 
(ListChangedType.PropertyDescriptorAdded,0,0));
+                       /* PropertyDescriptor Removed */
+                       if (args.Action == CollectionChangeAction.Remove)
+                               OnListChanged (new ListChangedEventArgs 
(ListChangedType.PropertyDescriptorDeleted,0,0));
+                       /* FIXME: PropertyDescriptor Changed ???*/
+                       if (args.Action == CollectionChangeAction.Refresh)
+                               OnListChanged (new ListChangedEventArgs 
(ListChangedType.PropertyDescriptorChanged,0,0));
+               }
+
                // internal use by Mono
                protected void Reset() 
                {

Modified: trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2006-12-07 
22:36:39 UTC (rev 69210)
+++ trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2006-12-07 
22:39:54 UTC (rev 69211)
@@ -1,3 +1,8 @@
+2006-12-07  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * DataViewTest.cs: add unit test for parent/child relation
+       changes.
+
 2006-12-07  Nagappan A  <[EMAIL PROTECTED]>
 
        * DataTableTest3.cs, DataTableTest4.cs: Added new test-cases to test

Modified: trunk/mcs/class/System.Data/Test/System.Data/DataViewTest.cs
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/DataViewTest.cs        
2006-12-07 22:36:39 UTC (rev 69210)
+++ trunk/mcs/class/System.Data/Test/System.Data/DataViewTest.cs        
2006-12-07 22:39:54 UTC (rev 69211)
@@ -345,14 +345,20 @@
                        dataView.AllowNew = true;
                        DataRowView drv = dataView.AddNew ();
                        AssertEquals 
("test#01",ListChangedType.ItemAdded,listChangedArgs.ListChangedType);
-                       AssertEquals ("test#02",drv["itemName"],dataView 
[dataView.Count - 1]["itemName"]);
+                       AssertEquals ("test#02",-1,listChangedArgs.OldIndex);
+                       AssertEquals ("test#03",5,listChangedArgs.NewIndex);
+                       AssertEquals ("test#04",drv["itemName"],dataView 
[dataView.Count - 1]["itemName"]);
                        listChangedArgs = null;
                        drv["itemId"] = "item " + 1001;
                        drv["itemName"] = "name " + rndm.Next();
                        drv["itemPrice"] = "Rs. " + (rndm.Next() % 1000);
                        drv["itemCategory"] = "Cat " + ((rndm.Next() % 10) + 1);
                        // Actually no events are arisen when items are set.
-                       AssertNull ("test#03", listChangedArgs);
+                       AssertNull ("test#05", listChangedArgs);
+                       drv.CancelEdit ();
+                       AssertEquals 
("test#06",ListChangedType.ItemDeleted,listChangedArgs.ListChangedType);
+                       AssertEquals ("test#07",-1,listChangedArgs.OldIndex);
+                       AssertEquals ("test#08",5,listChangedArgs.NewIndex);
                }
 
                [Test]
@@ -687,6 +693,65 @@
 
                [Test]
                [NUnit.Framework.Category ("NotWorking")]
+               public void ComplexEventSequence2 ()
+               {
+                       string result = @"setting table...
+---- OnListChanged PropertyDescriptorChanged,0,0
+----- UpdateIndex : True
+---- OnListChanged Reset,-1,-1
+table was set.
+---- OnListChanged PropertyDescriptorAdded,0,0
+ col1 added.
+---- OnListChanged PropertyDescriptorAdded,0,0
+ col2 added.
+---- OnListChanged PropertyDescriptorAdded,0,0
+ col3 added.
+---- OnListChanged Reset,-1,-1
+added tables to dataset
+---- OnListChanged PropertyDescriptorAdded,0,0
+added relation 1
+---- OnListChanged PropertyDescriptorAdded,0,0
+added relation 2
+---- OnListChanged PropertyDescriptorDeleted,0,0
+removed relation 2
+";
+
+                       eventWriter = new StringWriter ();
+
+                       DataSet ds = new DataSet ();
+                       DataTable dt = new DataTable ("table");
+                       DataTable dt2 = new DataTable ("table2");
+                       ComplexEventSequence1View dv =
+                               new ComplexEventSequence1View (dt, eventWriter);
+                       dt.Columns.Add ("col1");
+                       eventWriter.WriteLine (" col1 added.");
+                       dt.Columns.Add ("col2");
+                       eventWriter.WriteLine (" col2 added.");
+                       dt.Columns.Add ("col3");
+                       eventWriter.WriteLine (" col3 added.");
+
+                       dt2.Columns.Add ("col1");
+                       dt2.Columns.Add ("col2");
+                       dt2.Columns.Add ("col3");
+
+                       ds.Tables.Add (dt);
+                       ds.Tables.Add (dt2);
+
+                       eventWriter.WriteLine ("added tables to dataset");
+                       ds.Relations.Add ("Relation", dt.Columns ["col1"], 
dt2.Columns ["col1"]);
+                       eventWriter.WriteLine ("added relation 1");
+
+                       DataRelation dr = ds.Relations.Add ("Relation2", 
dt2.Columns ["col2"], dt.Columns ["col2"]);
+                       eventWriter.WriteLine ("added relation 2");
+
+                       ds.Relations.Remove (dr);
+                       eventWriter.WriteLine ("removed relation 2");
+
+                       AssertEquals (result, eventWriter.ToString ().Replace 
("\r\n", "\n"));
+               }
+
+               [Test]
+               [NUnit.Framework.Category ("NotWorking")]
                public void ComplexEventSequence1 ()
                {
                        string result = @"setting table...

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

Reply via email to