Merge pull request #1624 from esdrubal/getprocesstimes
[mono.git] / mcs / class / System.Data / Test / System.Data / DataColumnCollectionTest.cs
index f6b09c74db7c8374c0b7af9ba405d659a294eab3..aac4a3a35c08c3ec87b0e3bd0e63ff09de2884f8 100644 (file)
@@ -43,12 +43,12 @@ namespace MonoTests.System.Data
        [TestFixture]
        public class DataColumnCollectionTest
        {
-               private DataTable _tbl;
+               //private DataTable _tbl;
 
                [SetUp]
                public void GetReady () 
                {
-                       _tbl = new DataTable();
+                       //_tbl = new DataTable();
                }
 
                //TODO
@@ -196,6 +196,70 @@ namespace MonoTests.System.Data
                        Assert.IsFalse (C.Unique, "test#110"); 
                }
 
+               [Test] // Add (String)
+               public void Add3_ColumnName_Empty ()
+               {
+                       DataTable table = new DataTable ();
+                       DataColumnCollection cols = table.Columns;
+                       DataColumn col;
+
+                       col = cols.Add (string.Empty);
+                       Assert.AreEqual (1, cols.Count, "#A1");
+                       Assert.AreEqual ("Column1", col.ColumnName, "#A2");
+                       Assert.AreSame (table, col.Table, "#A3");
+
+                       col = cols.Add (string.Empty);
+                       Assert.AreEqual (2, cols.Count, "#B1");
+                       Assert.AreEqual ("Column2", col.ColumnName, "#B2");
+                       Assert.AreSame (table, col.Table, "#B3");
+
+                       cols.RemoveAt (1);
+
+                       col = cols.Add (string.Empty);
+                       Assert.AreEqual (2, cols.Count, "#C1");
+                       Assert.AreEqual ("Column2", col.ColumnName, "#C2");
+                       Assert.AreSame (table, col.Table, "#C3");
+
+                       cols.Clear ();
+
+                       col = cols.Add (string.Empty);
+                       Assert.AreEqual (1, cols.Count, "#D1");
+                       Assert.AreEqual ("Column1", col.ColumnName, "#D2");
+                       Assert.AreSame (table, col.Table, "#D3");
+               }
+
+               [Test] // Add (String)
+               public void Add3_ColumnName_Null ()
+               {
+                       DataTable table = new DataTable ();
+                       DataColumnCollection cols = table.Columns;
+                       DataColumn col;
+                       
+                       col = cols.Add ((string) null);
+                       Assert.AreEqual (1, cols.Count, "#A1");
+                       Assert.AreEqual ("Column1", col.ColumnName, "#A2");
+                       Assert.AreSame (table, col.Table, "#A3");
+
+                       col = cols.Add ((string) null);
+                       Assert.AreEqual (2, cols.Count, "#B1");
+                       Assert.AreEqual ("Column2", col.ColumnName, "#B2");
+                       Assert.AreSame (table, col.Table, "#B3");
+
+                       cols.RemoveAt (1);
+
+                       col = cols.Add ((string) null);
+                       Assert.AreEqual (2, cols.Count, "#C1");
+                       Assert.AreEqual ("Column2", col.ColumnName, "#C2");
+                       Assert.AreSame (table, col.Table, "#C3");
+
+                       cols.Clear ();
+
+                       col = cols.Add ((string) null);
+                       Assert.AreEqual (1, cols.Count, "#D1");
+                       Assert.AreEqual ("Column1", col.ColumnName, "#D2");
+                       Assert.AreSame (table, col.Table, "#D3");
+               }
+
                [Test]
                public void AddExceptions ()
                {
@@ -346,10 +410,10 @@ namespace MonoTests.System.Data
                        DataColumnCollection Cols2 = Table2.Columns;
                        Assert.IsTrue (Cols2.CanRemove (C), "test#04");
 
-                       DataRelation Rel = new DataRelation ("Rel", Table.Columns [0], Table2.Columns [0]);
                        DataSet Set = new DataSet ();
                        Set.Tables.Add (Table);
                        Set.Tables.Add (Table2);
+                       DataRelation Rel = new DataRelation ("Rel", Table.Columns [0], Table2.Columns [0]);
                        Set.Relations.Add (Rel);
 
                        Assert.IsFalse (Cols2.CanRemove (C), "test#05");
@@ -385,7 +449,8 @@ namespace MonoTests.System.Data
                                Assert.Fail ("test#02");
                        } catch (Exception e) {
                                Assert.AreEqual (typeof (ArgumentException), e.GetType (), "test#03");
-                               Assert.AreEqual ("Cannot remove this column, because it is part of the parent key for relationship Rel.", e.Message, "test#04");
+                               // Never premise English.
+                               //Assert.AreEqual ("Cannot remove this column, because it is part of the parent key for relationship Rel.", e.Message, "test#04");
                        }
                }
 
@@ -510,7 +575,8 @@ namespace MonoTests.System.Data
                                Assert.Fail ("test#04");
                        } catch (Exception e) {
                                Assert.AreEqual (typeof (ArgumentException), e.GetType (), "test#05");
-                               Assert.AreEqual ("Column '_test_' does not belong to table test_table.", e.Message, "test#06");
+                               // Never premise English.
+                               //Assert.AreEqual ("Column '_test_' does not belong to table test_table.", e.Message, "test#06");
                        }
 
                        Cols.Add ();
@@ -529,7 +595,8 @@ namespace MonoTests.System.Data
                                Assert.Fail ("test#10");
                        } catch (Exception e) {
                                Assert.AreEqual (typeof (ArgumentException), e.GetType (), "test#11");
-                               Assert.AreEqual ("Cannot remove a column that doesn't belong to this table.", e.Message, "test#12");
+                               // Never premise English.
+                               //Assert.AreEqual ("Cannot remove a column that doesn't belong to this table.", e.Message, "test#12");
                        }
 
                        Cols.Add ();
@@ -551,7 +618,8 @@ namespace MonoTests.System.Data
                                Assert.Fail ("test#17");
                        } catch (Exception e) {
                                Assert.AreEqual (typeof (IndexOutOfRangeException), e.GetType (), "test#18");
-                               Assert.AreEqual ("Cannot find column 10.", e.Message, "test#19");
+                               // Never premise English.
+                               //Assert.AreEqual ("Cannot find column 10.", e.Message, "test#19");
                        }
                }
 
@@ -570,9 +638,6 @@ namespace MonoTests.System.Data
                }       
 
                [Test]
-#if TARGET_JVM
-               [Ignore ("Does not work with TARGET_JVM")]
-#endif
                public void ToStringTest ()
                {
                        DataTable Table = new DataTable ("test_table");