[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-patches
Subject:    [Mono-patches] r62153 - in trunk/mcs/class/System.Data: System.Data
From:       "senga (tsenganal () novell ! com)" <mono-patches-list () lists ! ximian ! com>
Date:       2006-06-30 10:10:49
Message-ID: 20060630101049.9A9849472C () mono-cvs ! ximian ! com
[Download RAW message or body]

Author: senga
Date: 2006-06-30 06:10:49 -0400 (Fri, 30 Jun 2006)
New Revision: 62153

Modified:
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataRow.cs
   trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
   trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
Log:
2006-06-30  Senganal T <tsenganal@novell.com>

	* Test/System.Data/DataRowTest2.cs : Added tests for new 2.0 methods in DataRow
	* System.Data/DataRow.cs : 
		- SetAdded, SetModified : new methods in 2.0


Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog	2006-06-30 09:58:19 UTC (rev \
                62152)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog	2006-06-30 10:10:49 UTC (rev \
62153) @@ -1,4 +1,9 @@
 2006-06-30  Senganal T  <tsenganal@novell.com>
+
+	* DataRow.cs : 
+		- SetAdded, SetModified : new methods in 2.0
+
+2006-06-30  Senganal T  <tsenganal@novell.com>
 	* SerializationFormat.cs, DataSetDateTime.cs, DataTableNewRowEventArgs.cs,
 	DataTableNewRowEventHandler.cs : Added 
 	* SyntaxErrorException.cs EvaluateException.cs StrongTypingException.cs 

Modified: trunk/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRow.cs	2006-06-30 09:58:19 UTC (rev \
                62152)
+++ trunk/mcs/class/System.Data/System.Data/DataRow.cs	2006-06-30 10:10:49 UTC (rev \
62153) @@ -336,6 +336,23 @@
 			}
 		}
 
+#if NET_2_0
+		public void SetAdded ()
+		{
+			if (RowState != DataRowState.Unchanged)
+				throw new InvalidOperationException ("SetAdded and SetModified can only be \
called on DataRows with Unchanged DataRowState."); +			Original = -1;
+		}
+
+		public void SetModified ()
+		{
+			if (RowState != DataRowState.Unchanged)
+				throw new InvalidOperationException ("SetAdded and SetModified can only be \
called on DataRows with Unchanged DataRowState."); +			Current = \
_table.RecordCache.NewRecord (); +			_table.RecordCache.CopyRecord (_table, Original, \
Current); +		}
+#endif
+
 		/// <summary>
 		/// Gets the DataTable for which this row has a schema.
 		/// </summary>

Modified: trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/ChangeLog	2006-06-30 09:58:19 UTC \
                (rev 62152)
+++ trunk/mcs/class/System.Data/Test/System.Data/ChangeLog	2006-06-30 10:10:49 UTC \
(rev 62153) @@ -1,3 +1,7 @@
+2006-06-30  Senganal T <tsenganal@novell.com>
+
+	* DataRowTest2.cs : Added tests for new 2.0 methods in DataRow
+
 2006-06-28  Senganal T <tsenganal@novell.com>
 
 	* DataSetTest2.cs :  Removed ReadXml_Strm, ReadXml_Strg

Modified: trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs	2006-06-30 09:58:19 \
                UTC (rev 62152)
+++ trunk/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs	2006-06-30 10:10:49 \
UTC (rev 62153) @@ -1616,5 +1616,123 @@
 				Assert.Fail("DRW147: Wrong exception type. Got:" + exc);
 			}
 		}
+
+#if NET_2_0
+		string SetAddedModified_ErrMsg = "SetAdded and SetModified can only be called on \
DataRows with Unchanged DataRowState."; +		[Test]
+		public void SetAdded_test()
+		{
+			DataTable table = new DataTable();
+
+			DataRow row = table.NewRow();
+			try {
+				row.SetAdded();
+				Assert.Fail ("#1");
+			} catch (InvalidOperationException e) {
+				Assert.AreEqual (SetAddedModified_ErrMsg, e.Message, "#2");
+			}
+
+			table.Columns.Add("col1", typeof(int));
+			table.Columns.Add("col2", typeof(int));
+			table.Columns.Add("col3", typeof(int));
+
+			row = table.Rows.Add(new object[] { 1, 2, 3 });
+			Assert.AreEqual(DataRowState.Added, row.RowState, "#1");
+			try {
+				row.SetAdded();
+				Assert.Fail ("#2");
+			} catch (InvalidOperationException e) {
+				Assert.AreEqual (SetAddedModified_ErrMsg, e.Message, "#2");
+			}
+			Assert.AreEqual(DataRowState.Added, row.RowState, "#2");
+
+			row.AcceptChanges();
+			row[0] = 10;
+			Assert.AreEqual(DataRowState.Modified, row.RowState, "#5");
+			try {
+				row.SetAdded();
+				Assert.Fail ("#3");
+			} catch (InvalidOperationException e) {
+				Assert.AreEqual (SetAddedModified_ErrMsg, e.Message, "#2");
+			}
+
+			row.AcceptChanges();
+			Assert.AreEqual(DataRowState.Unchanged, row.RowState, "#3");
+			row.SetAdded();
+			Assert.AreEqual(DataRowState.Added, row.RowState, "#4");
+		}
+
+		[Test]
+		public void setAdded_testRollback ()
+		{
+			DataTable table = new DataTable ();
+			table.Columns.Add ("col1", typeof (int));
+			table.Columns.Add ("col2", typeof (int));
+
+			table.Rows.Add (new object[] {1,1});
+			table.AcceptChanges ();
+
+			table.Rows [0].SetAdded ();
+			table.RejectChanges ();
+			Assert.AreEqual (0, table.Rows.Count, "#1");
+		}
+
+		[Test]
+		public void SetModified_test()
+		{
+			DataTable table = new DataTable();
+
+			DataRow row = table.NewRow();
+			try {
+				row.SetModified ();
+			} catch (InvalidOperationException) {}
+
+			table.Columns.Add("col1", typeof(int));
+			table.Columns.Add("col2", typeof(int));
+			table.Columns.Add("col3", typeof(int));
+
+			row = table.Rows.Add(new object[] { 1, 2, 3 });
+			Assert.AreEqual(DataRowState.Added, row.RowState, "#1");
+			try {
+				row.SetModified();
+				Assert.Fail ("#1");
+			} catch (InvalidOperationException e) {
+				Assert.AreEqual (SetAddedModified_ErrMsg, e.Message, "#2");
+			}
+
+			row.AcceptChanges();
+			row[0] = 10;
+			Assert.AreEqual(DataRowState.Modified, row.RowState, "#5");
+			try {
+				row.SetModified ();
+				Assert.Fail ("#2");
+			} catch (InvalidOperationException e) {
+				Assert.AreEqual (SetAddedModified_ErrMsg, e.Message, "#2");
+			}
+
+			row.AcceptChanges();
+			Assert.AreEqual(DataRowState.Unchanged, row.RowState, "#3");
+			row.SetModified ();
+			Assert.AreEqual(DataRowState.Modified, row.RowState, "#4");
+		}
+
+		[Test]
+		public void setModified_testRollback()
+		{
+			DataTable table = new DataTable();
+			table.Columns.Add("col1", typeof(int));
+			table.Columns.Add("col2", typeof(int));
+
+			DataRow row = table.Rows.Add(new object[] { 1, 1 });
+			table.AcceptChanges();
+
+			row.SetModified ();
+			Assert.AreEqual(row.RowState, DataRowState.Modified, "#0");
+			Assert.AreEqual(1, row [0, DataRowVersion.Current], "#1");
+			Assert.AreEqual(1, row [0, DataRowVersion.Original], "#2");
+			table.RejectChanges ();
+			Assert.AreEqual(row.RowState, DataRowState.Unchanged, "#3");
+		}
+#endif
 	}
 }

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic