2004-05-05 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 5 May 2004 02:59:48 +0000 (02:59 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 5 May 2004 02:59:48 +0000 (02:59 -0000)
* ConstraintCollectionTest.cs : uncommented some tests that should be
  implemented until mono 1.0.
* ConstraintTest.cs : use ExpectedException. Don't expect localizable
  error message.
* DataColumnTest.cs,
  DataRelationTest.cs,
  DataRowCollectionTest.cs : catch only specific type exception.
  Don't rely on (test) localizable messages.
* DataSetAssertion.cs : We shouldn't expect exact column ordinals
  when infering/reading the structures from documents/schemas.

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

mcs/class/System.Data/Test/System.Data/ChangeLog
mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest.cs
mcs/class/System.Data/Test/System.Data/ConstraintTest.cs
mcs/class/System.Data/Test/System.Data/DataColumnTest.cs
mcs/class/System.Data/Test/System.Data/DataRelationTest.cs
mcs/class/System.Data/Test/System.Data/DataRowCollectionTest.cs
mcs/class/System.Data/Test/System.Data/DataSetAssertion.cs

index 704b9358073688b5447448deec413b147cb2a818..4dc0f19a6e54a375ef1ee730de39de1f51aa3a97 100644 (file)
@@ -1,3 +1,16 @@
+2004-05-05  Atsushi Enomoto <atsushi@ximian.com>
+
+       * ConstraintCollectionTest.cs : uncommented some tests that should be
+         implemented until mono 1.0.
+       * ConstraintTest.cs : use ExpectedException. Don't expect localizable
+         error message.
+       * DataColumnTest.cs,
+         DataRelationTest.cs,
+         DataRowCollectionTest.cs : catch only specific type exception.
+         Don't rely on (test) localizable messages.
+       * DataSetAssertion.cs : We shouldn't expect exact column ordinals
+         when infering/reading the structures from documents/schemas.
+
 2004-04-29  Atsushi Enomoto <atsushi@ximian.com>
 
        * DataRowTest.cs : Added a test for auto increment column and item
index 480441daefbf3b6a90c76413d9adac64ea9c146e..43ab658215c5caa9087122e666c8cce232eeac39 100644 (file)
@@ -90,17 +90,17 @@ namespace MonoTests.System.Data
                                col.Remove (_constraint2); // only for !1.0
                                col.Remove (_constraint1);
                        }
+#if ! NET_1_1
                        catch (DuplicateNameException) {
-#if NET_1_1
-                               throw;
-#endif
                        }
+#endif
                        catch (AssertionException exc) {throw exc;}
+/* Don't use such catch. They cover our eyes from the exact exception location.
                        catch (Exception exc)
                        {
                                Fail("A2: Wrong exception type. " + exc.ToString());
                        }
-
+*/
                        //Constraint Already exists
                        try 
                        {
@@ -214,97 +214,94 @@ namespace MonoTests.System.Data
 
                }
 
-               //TODO: Implementation not ready for this test yet
-               //[Test]
-//             public void AddFkException1()
-//             {
-//                     DataSet ds = new DataSet();
-//                     ds.Tables.Add(_table);
-//                     ds.Tables.Add(_table2);
-//
-//                     _table.Rows.Add(new object [] {1});
-//                     _table.Rows.Add(new object [] {1});
-//
-//                     //FKC: can't create unique constraint because duplicate values already exist
-//                     try
-//                     {
-//                             ForeignKeyConstraint fkc = new ForeignKeyConstraint( _table.Columns[0],
-//                                                                                     _table2.Columns[0]);
-//                             
-//                             _table2.Constraints.Add(fkc);   //should throw                  
-//                             Fail("B1: Failed to throw ArgumentException.");
-//                     }
-//                     catch (ArgumentException) {}
-//                     catch (AssertionException exc) {throw exc;}
-//                     catch (Exception exc)
-//                     {
-//                             Fail("A1: Wrong Exception type. " + exc.ToString());
-//                     }
-//
-//
-//             }
-
-
-               //TODO: Implementation not ready for this test yet
-               //[Test]
-//             public void AddFkException2()
-//             {
-//                     //Foreign key rules only work when the tables
-//                     //are apart of the dataset
-//                     DataSet ds = new DataSet();
-//                     ds.Tables.Add(_table);
-//                     ds.Tables.Add(_table2);
-//
-//                     _table.Rows.Add(new object [] {1});
-//                     
-//                     // will need a matching parent value in 
-//                     // _table
-//                     _table2.Rows.Add(new object [] {3}); 
-//                                                             
-//
-//                     //FKC: no matching parent value
-//                     try
-//                     {
-//                             ForeignKeyConstraint fkc = new ForeignKeyConstraint( _table.Columns[0],
-//                                     _table2.Columns[0]);
-//                             
-//                             _table2.Constraints.Add(fkc);   //should throw                  
-//                             Fail("B1: Failed to throw ArgumentException.");
-//                     }
-//                     catch (ArgumentException) {}
-//                     catch (AssertionException exc) {throw exc;}
-//                     catch (Exception exc)
-//                     {
-//                             Fail("A1: Wrong Exception type. " + exc.ToString());
-//                     }
-//
-//
-//             }
+               [Test]
+               public void AddFkException1()
+               {
+                       DataSet ds = new DataSet();
+                       ds.Tables.Add(_table);
+                       ds.Tables.Add(_table2);
 
+                       _table.Rows.Add(new object [] {1});
+                       _table.Rows.Add(new object [] {1});
 
-               //TODO: Implementation not ready for this test yet
-               //[Test]
-//             public void AddUniqueExceptions()
-//             {
-//                     
-//
-//                     //UC: can't create unique constraint because duplicate values already exist
-//                     try
-//                     {
-//                             _table.Rows.Add(new object [] {1});
-//                             _table.Rows.Add(new object [] {1});
-//                             UniqueConstraint uc = new UniqueConstraint( _table.Columns[0]);
-//                             
-//                             _table.Constraints.Add(uc);     //should throw                  
-//                             Fail("B1: Failed to throw ArgumentException.");
-//                     }
-//                     catch (ArgumentException) {}
-//                     catch (AssertionException exc) {throw exc;}
-//                     catch (Exception exc)
-//                     {
-//                             Fail("A1: Wrong Exception type. " + exc.ToString());
-//                     }
-//             }
+                       //FKC: can't create unique constraint because duplicate values already exist
+                       try
+                       {
+                               ForeignKeyConstraint fkc = new ForeignKeyConstraint( _table.Columns[0],
+                                                                                       _table2.Columns[0]);
+                               
+                               _table2.Constraints.Add(fkc);   //should throw                  
+                               Fail("B1: Failed to throw ArgumentException.");
+                       }
+                       catch (ArgumentException) {}
+                       catch (AssertionException exc) {throw exc;}
+                       catch (Exception exc)
+                       {
+                               Fail("A1: Wrong Exception type. " + exc.ToString());
+                       }
+
+
+               }
+
+
+               [Test]
+               public void AddFkException2()
+               {
+                       //Foreign key rules only work when the tables
+                       //are apart of the dataset
+                       DataSet ds = new DataSet();
+                       ds.Tables.Add(_table);
+                       ds.Tables.Add(_table2);
+
+                       _table.Rows.Add(new object [] {1});
+                       
+                       // will need a matching parent value in 
+                       // _table
+                       _table2.Rows.Add(new object [] {3}); 
+                                                               
+
+                       //FKC: no matching parent value
+                       try
+                       {
+                               ForeignKeyConstraint fkc = new ForeignKeyConstraint( _table.Columns[0],
+                                       _table2.Columns[0]);
+                               
+                               _table2.Constraints.Add(fkc);   //should throw                  
+                               Fail("B1: Failed to throw ArgumentException.");
+                       }
+                       catch (ArgumentException) {}
+                       catch (AssertionException exc) {throw exc;}
+                       catch (Exception exc)
+                       {
+                               Fail("A1: Wrong Exception type. " + exc.ToString());
+                       }
+
+
+               }
+
+
+               [Test]
+               public void AddUniqueExceptions()
+               {
+                       
+
+                       //UC: can't create unique constraint because duplicate values already exist
+                       try
+                       {
+                               _table.Rows.Add(new object [] {1});
+                               _table.Rows.Add(new object [] {1});
+                               UniqueConstraint uc = new UniqueConstraint( _table.Columns[0]);
+                               
+                               _table.Constraints.Add(uc);     //should throw                  
+                               Fail("B1: Failed to throw ArgumentException.");
+                       }
+                       catch (ArgumentException) {}
+                       catch (AssertionException exc) {throw exc;}
+                       catch (Exception exc)
+                       {
+                               Fail("A1: Wrong Exception type. " + exc.ToString());
+                       }
+               }
 
                [Test]
                 //Tests AddRange (), CanRemove (), RemoveAt (), Remove (), Exceptions of  Remove(), and Clear ()
index 8ce9898ffddf70923c5170ca08e2435d30d48482..e9706eb5d169c8e60e4c1fa663e6ffe8c0acdc66 100644 (file)
@@ -90,26 +90,17 @@ namespace MonoTests.System.Data
                }
 
                [Test]
-               public void SetConstraintNameDuplicateException() {
+               [ExpectedException (typeof (DuplicateNameException))]
+               public void SetConstraintNameDuplicateException ()
+               {
                        _constraint1.ConstraintName = "Dog";
                        _constraint2.ConstraintName = "Cat";
 
                        _table.Constraints.Add(_constraint1);
                        _table.Constraints.Add(_constraint2);
 
-                       try {
-                               //Should throw DuplicateNameException
-                               _constraint2.ConstraintName = "Dog";
-                       
-                               Fail("Failed to throw " + 
-                                       " DuplicateNameException exception.");
-                       }       
-                       catch (DuplicateNameException) {}
-                       catch (AssertionException exc) {throw exc;}
-                       catch {
-                               Fail("Wrong exception type thrown.");
-                       }
-               
+                       //Should throw DuplicateNameException
+                       _constraint2.ConstraintName = "Dog";
                }
 
                [Test]
index c45c6432adcc64c27c748ea0a27c92de272bc4fa..e2dfdd359e98eb1015b03b38e8fbf81c0903cead 100644 (file)
@@ -341,9 +341,9 @@ namespace MonoTests.System.Data
                        try {
                                C.Expression = "iif (nimi = 24, 'hurrey', 'boo')";
                                Fail ("DC36");
-                       } catch (Exception e) {                                         
-                               AssertEquals ("DC37", typeof (EvaluateException), e.GetType ());
-                               AssertEquals ("DC38", "Cannot find column [nimi].", e.Message);
+                       } catch (EvaluateException e) {                                         
+//                             AssertEquals ("DC37", typeof (EvaluateException), e.GetType ());
+//                             AssertEquals ("DC38", "Cannot find column [nimi].", e.Message);
                        }
                        
                        try {
index 7d5a26688518df540a02786c002bf8828273bd94..450b96dde4ab9476dced9e9b10a7b48f9961d73a 100644 (file)
@@ -245,9 +245,9 @@ namespace MonoTests.System.Data
                        try {\r
                                Relation = new DataRelation ("Rel", Parents, Childs);\r
                                Fail ("test#01");\r
-                       } catch (Exception e) {\r
-                               AssertEquals ("test#02", typeof (InvalidConstraintException), e.GetType ());                            \r
-                               AssertEquals ("test#03", "Cannot create a Key from Columns that belong to different tables.", e.Message);\r
+                       } catch (InvalidConstraintException e) {\r
+//                             AssertEquals ("test#02", typeof (InvalidConstraintException), e.GetType ());                            \r
+//                             AssertEquals ("test#03", "Cannot create a Key from Columns that belong to different tables.", e.Message);\r
                        }\r
                        \r
                        Childs [1] = Col6;\r
index e2ad7914afb115dfedfe376f5902c34e6c589701..ec28b585d6cff8dad4ee79aa824790b86eebd210 100644 (file)
@@ -172,9 +172,9 @@ namespace MonoTests.System.Data
                        try {
                                Rows.Add (obs);
                                Fail ("test#25");
-                       } catch (Exception e) {
+                       } catch (ArgumentException e) {
                                // LAMESPEC: MSDN says this exception is InvalidCastException
-                               AssertEquals ("test#26", typeof (ArgumentException), e.GetType ());
+//                             AssertEquals ("test#26", typeof (ArgumentException), e.GetType ());
                        }
 
                        object [] obs1 = new object [5];
index 2c32971b532f4f8a60728a100f05bb67da3f8c1e..af90c4cefab04d8fd3c10408a5e6ed69af2beb9e 100755 (executable)
@@ -118,7 +118,7 @@ namespace MonoTests.System.Data
                        AssertEquals (label + "Expression: " , expression, col.Expression);\r
                        AssertEquals (label + "MaxLength: " , maxLength, col.MaxLength);\r
                        AssertEquals (label + "Namespace: " , ns, col.Namespace);\r
-                       AssertEquals (label + "Ordinal: " , ordinal, col.Ordinal);\r
+//                     AssertEquals (label + "Ordinal: " , ordinal, col.Ordinal);\r
                        AssertEquals (label + "Prefix: " , prefix, col.Prefix);\r
                        AssertEquals (label + "ReadOnly: " , readOnly, col.ReadOnly);\r
                        AssertEquals (label + "Unique: " , unique, col.Unique);\r