[TestFixture]
public class DataColumnCollectionTest
{
- private DataTable _tbl;
+ //private DataTable _tbl;
[SetUp]
public void GetReady ()
{
- _tbl = new DataTable();
+ //_tbl = new DataTable();
}
//TODO
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 ()
{
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");
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");
}
}
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 ();
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 ();
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");
}
}
}
[Test]
-#if TARGET_JVM
- [Ignore ("Does not work with TARGET_JVM")]
-#endif
public void ToStringTest ()
{
DataTable Table = new DataTable ("test_table");