Author: borisk
Date: 2005-05-31 08:01:30 -0400 (Tue, 31 May 2005)
New Revision: 45260

Added:
   
trunk/mcs/class/System.Data/Test/System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/
   
trunk/mcs/class/System.Data/Test/System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
Modified:
   trunk/mcs/class/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataRow.cs
   trunk/mcs/class/System.Data/System.Data_test.dll.sources
Log:
DataRow.cs : SetParentRow on Detached row with no Default version throws an 
exception. Added RowNotInTableException_Generate.cs test

Modified: trunk/mcs/class/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/ChangeLog       2005-05-31 11:56:25 UTC (rev 
45259)
+++ trunk/mcs/class/System.Data/ChangeLog       2005-05-31 12:01:30 UTC (rev 
45260)
@@ -1,3 +1,6 @@
+2005-05-31 Boris Kirzner <[EMAIL PROTECTED]>
+               * System.Data_test.dll.sources : added 
System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
+               
 2005-05-30 BorisKirzner <[EMAIL PROTECTED]>
                * System.Data.SqlClient.jvm
                * System.Data.Configuration.jvm

Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-31 11:56:25 UTC 
(rev 45259)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-31 12:01:30 UTC 
(rev 45260)
@@ -1,3 +1,6 @@
+2005-05-31 Boris Kirzner <[EMAIL PROTECTED]>
+       * DataRow.cs : SetParentRow on Detached row with no Default version 
throws an exception.
+       
 2005-05-29 Konstantin Triger <[EMAIL PROTECTED]>
 
        * This patch fixes #74813

Modified: trunk/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-05-31 11:56:25 UTC 
(rev 45259)
+++ trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-05-31 12:01:30 UTC 
(rev 45260)
@@ -1393,6 +1393,11 @@
 
                        if (parentRow != null && _table.DataSet != 
parentRow.Table.DataSet)
                                throw new ArgumentException();
+
+                       if (RowState == DataRowState.Detached && 
!HasVersion(DataRowVersion.Default)) {
+                               // the row should have default data to access, 
i.e. we can do this for the newly created row, but not for the row once deleted 
from the table
+                               throw new RowNotInTableException("This row has 
been removed from a table and does not have any data.  BeginEdit() will allow 
creation of new data in this row.");
+                       }
                        
                        BeginEdit();
 

Modified: trunk/mcs/class/System.Data/System.Data_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Data/System.Data_test.dll.sources    2005-05-31 
11:56:25 UTC (rev 45259)
+++ trunk/mcs/class/System.Data/System.Data_test.dll.sources    2005-05-31 
12:01:30 UTC (rev 45260)
@@ -334,6 +334,7 @@
 
System.Data.Tests.Mainsoft/System.Data/InvalidConstraintException/InvalidConstraintException_Generate.cs
 
System.Data.Tests.Mainsoft/System.Data/NoNullAllowedException/NoNullAllowedException_Generate.cs
 
System.Data.Tests.Mainsoft/System.Data/ReadOnlyException/ReadOnlyException_Generate.cs
+System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
 
System.Data.Tests.Mainsoft/System.Data/SyntaxErrorException/SyntaxErrorException_Generate.cs
 
System.Data.Tests.Mainsoft/System.Data/UniqueConstraint/UniqueConstraint_Columns.cs
 
System.Data.Tests.Mainsoft/System.Data/UniqueConstraint/UniqueConstraint_constraintName.cs

Added: 
trunk/mcs/class/System.Data/Test/System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
===================================================================
--- 
trunk/mcs/class/System.Data/Test/System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
   2005-05-31 11:56:25 UTC (rev 45259)
+++ 
trunk/mcs/class/System.Data/Test/System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
   2005-05-31 12:01:30 UTC (rev 45260)
@@ -0,0 +1,213 @@
+// Authors:
+//   Rafael Mizrahi   <[EMAIL PROTECTED]>
+//   Erez Lotan       <[EMAIL PROTECTED]>
+//   Oren Gurfinkel   <[EMAIL PROTECTED]>
+//   Ofer Borstein
+// 
+// Copyright (c) 2004 Mainsoft Co.
+// 
+// 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.
+//
+
+using NUnit.Framework;
+
+
+using System;
+using System.Data;
+
+using GHTUtils;
+using GHTUtils.Base;
+
+namespace tests.system_data_dll.System_Data
+{
+[TestFixture] public class RowNotInTableException_Generate : GHTBase
+{
+       [Test] public void Main()
+       {
+               RowNotInTableException_Generate tc = new 
RowNotInTableException_Generate();
+               Exception exp = null;
+               try
+               {
+                       tc.BeginTest("RowNotInTableException");
+                       tc.run();
+               }
+               catch(Exception ex)
+               {
+                       exp = ex;
+               }
+               finally
+               {
+                       tc.EndTest(exp);
+               }
+       }
+
+       //Activate This Construntor to log All To Standard output
+       //public TestClass():base(true){}
+
+       //Activate this constructor to log Failures to a log file
+       //public TestClass(System.IO.TextWriter tw):base(tw, false){}
+
+
+       //Activate this constructor to log All to a log file
+       //public TestClass(System.IO.TextWriter tw):base(tw, true){}
+
+       //BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
+
+       public void run()
+       {
+               Exception exp = null;
+               Exception tmpEx = new Exception() ;
+
+               DataSet ds = new DataSet();
+               ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
+               ds.Tables.Add(GHTUtils.DataProvider.CreateChildDataTable());
+               ds.Relations.Add(new 
DataRelation("myRelation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
+
+               DataRow drParent = ds.Tables[0].Rows[0];
+               DataRow drChild = ds.Tables[1].Rows[0];
+               drParent.Delete();
+               drChild.Delete();
+               ds.AcceptChanges();
+        
+               try
+               {
+                       BeginCase("RowNotInTableException - AcceptChanges");
+                       try
+                       {
+                               drParent.AcceptChanges();
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+
+               try
+               {
+                       BeginCase("RowNotInTableException - GetChildRows");
+                       try
+                       {
+                               drParent.GetChildRows("myRelation");
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+
+               try
+               {
+                       BeginCase("RowNotInTableException - ItemArray");
+                       object[] o = null;
+                       try
+                       {
+                               o = drParent.ItemArray ;
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+
+               // **********   don't throw exception (should be according to 
MSDN)     ***********************
+               //              try
+               //              {
+               //                      BeginCase("RowNotInTableException - 
GetParentRow");
+               //                      DataRow dr = null;
+               //                      try
+               //                      {
+               //                              dr = 
drChild.GetParentRow("myRelation"); 
+               //                      }
+               //                      catch (RowNotInTableException  ex)
+               //                      {
+               //                              tmpEx = ex;
+               //                      }
+               //                      
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+               //                      tmpEx = new  Exception();
+               //              }
+               //              catch(Exception ex)     {exp = ex;}
+               //              finally {EndCase(exp); exp = null;}
+               
+               try
+               {
+                       BeginCase("RowNotInTableException - GetParentRows");
+                       DataRow[] dr = null;
+                       try
+                       {
+                               dr = drChild.GetParentRows("myRelation"); 
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+
+               try
+               {
+                       BeginCase("RowNotInTableException - RejectChanges");
+                       try
+                       {
+                               drParent.RejectChanges();
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+
+               try
+               {
+                       BeginCase("RowNotInTableException - SetParentRow");
+                       try
+                       {
+                               drChild.SetParentRow(ds.Tables[0].Rows[1]);
+                       }
+                       catch (RowNotInTableException  ex)
+                       {
+                               tmpEx = ex;
+                       }
+                       
base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
+                       tmpEx = new  Exception();
+               }
+               catch(Exception ex)     {exp = ex;}
+               finally {EndCase(exp); exp = null;}
+       }
+}
+}
\ No newline at end of file

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

Reply via email to