context: // DataColumnCollectionTest.cs - NUnit Test Cases for System.Data.DataColumnCollection
  //
  // Authors:
  //   Franklin Wise <gracenote@earthlink.net>
  //   Ville Palo <vi64pa@kolumbus.fi>
  //   Martin Willemoes Hansen <mwh@sysrq.dk>
  //
  // (C) Copyright 2002 Franklin Wise
  // (C) Copyright 2003 Ville Palo
  // (C) Copyright 2003 Martin Willemoes Hansen
  //
  
  //
  // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  //
  // 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 System.Xml;
  
  namespace MonoTests.System.Data
  {
  	[TestFixture]
  	public class DataColumnCollectionTest
  	{
  		//private DataTable _tbl;
  
  		[SetUp]
  		public void GetReady () 
  		{
  			//_tbl = new DataTable();
  		}
  
  		//TODO
  		[Test]
  		public void AddValidationExceptions()
  		{
  			
  			//Set DefaultValue and AutoIncr == true
  			//And get an exception
  		}
  
  		[Test]
  	        public void Add ()
  		{
  			DataTable Table = new DataTable ("test_table");
  			DataColumnCollection Cols = Table.Columns;
  			DataColumn C = null;
  			Cols.Add ();
  			Cols.Add ();
  	        	
  	        	C = Cols [0];
  			Assert.IsTrue (C.AllowDBNull, "test#01");
  			Assert.IsFalse (C.AutoIncrement, "test#02");
  			Assert.AreEqual (0L, C.AutoIncrementSeed, "test#03");
  			Assert.AreEqual (1L, C.AutoIncrementStep, "test#04");
  			Assert.AreEqual ("Column1", C.Caption, "test#05");
  			Assert.AreEqual ("Element", C.ColumnMapping.ToString (), "test#06");
  			Assert.AreEqual ("Column1", C.ColumnName, "test#07");
  			Assert.IsNull (C.Container, "test#08");
  			Assert.AreEqual (typeof (string), C.DataType, "test#09");
  			Assert.AreEqual (DBNull.Value, C.DefaultValue, "test#10");
  			Assert.IsFalse (C.DesignMode, "test#11");
  			Assert.AreEqual ("", C.Expression, "test#12");
  			Assert.AreEqual (0, C.ExtendedProperties.Count, "test#13");
  			Assert.AreEqual (-1, C.MaxLength, "test#14");
  			Assert.AreEqual ("", C.Namespace, "test#15");
  			Assert.AreEqual (0, C.Ordinal, "test#16");
  			Assert.AreEqual ("", C.Prefix, "test#17");
  			Assert.IsFalse (C.ReadOnly, "test#18");
  			Assert.IsNull (C.Site, "test#19");
  			Assert.AreEqual ("test_table", C.Table.TableName, "test#20");
  			Assert.AreEqual ("Column1", C.ToString (), "test#21");
  			Assert.IsFalse (C.Unique, "test#22");
  
  			C = Cols [1];
  			Assert.IsTrue (C.AllowDBNull, "test#23");
  			Assert.IsFalse (C.AutoIncrement, "test#24");
  			Assert.AreEqual (0L, C.AutoIncrementSeed, "test#25");
  			Assert.AreEqual (1L, C.AutoIncrementStep, "test#26");
  			Assert.AreEqual ("Column2", C.Caption, "test#27");
  			Assert.AreEqual ("Element", C.ColumnMapping.ToString (), "test#28");
  			Assert.AreEqual ("Column2", C.ColumnName, "test#29");
  			Assert.IsNull (C.Container, "test#30");
  			Assert.AreEqual (typeof (string), C.DataType, "test#31");
  			Assert.AreEqual (DBNull.Value, C.DefaultValue, "test#32");
  			Assert.IsFalse (C.DesignMode, "test#33");
  			Assert.AreEqual ("", C.Expression, "test#34");
  			Assert.AreEqual (0, C.ExtendedProperties.Count, "test#35");
  			Assert.AreEqual (-1, C.MaxLength, "test#36");
  			Assert.AreEqual ("", C.Namespace, "test#37");
  			Assert.AreEqual (1, C.Ordinal, "test#38");
  			Assert.AreEqual ("", C.Prefix, "test#39");
  			Assert.IsFalse (C.ReadOnly, "test#40");
  			Assert.IsNull (C.Site, "test#41");
  			Assert.AreEqual ("test_table", C.Table.TableName, "test#42");
  			Assert.AreEqual ("Column2", C.ToString (), "test#43");
  			Assert.IsFalse (C.Unique, "test#44");
  
  			Cols.Add ("test1", typeof (int), "");
  			Cols.Add ("test2", typeof (string), "Column1 + Column2");
  
  			C = Cols [2];
  			Assert.IsTrue (C.AllowDBNull, "test#45");
  			Assert.IsFalse (C.AutoIncrement, "test#46");
  			Assert.AreEqual (0L, C.AutoIncrementSeed, "test#47");
  			Assert.AreEqual (1L, C.AutoIncrementStep, "test#48");
  			Assert.AreEqual ("test1", C.Caption, "test#49");
  			Assert.AreEqual ("Element", C.ColumnMapping.ToString (), "test#50");
  			Assert.AreEqual ("test1", C.ColumnName, "test#51");
  			Assert.IsNull (C.Container, "test#52");
  			Assert.AreEqual (typeof (int), C.DataType, "test#53");
  			Assert.AreEqual (DBNull.Value, C.DefaultValue, "test#54");
  			Assert.IsFalse (C.DesignMode, "test#55");
  			Assert.AreEqual ("", C.Expression, "test#56");
  			Assert.AreEqual (0, C.ExtendedProperties.Count, "test#57");
  			Assert.AreEqual (-1, C.MaxLength, "test#58");
  			Assert.AreEqual ("", C.Namespace, "test#59");
  			Assert.AreEqual (2, C.Ordinal, "test#60");
  			Assert.AreEqual ("", C.Prefix, "test#61");
  			Assert.IsFalse (C.ReadOnly, "test#62");
  			Assert.IsNull (C.Site, "test#63");
  			Assert.AreEqual ("test_table", C.Table.TableName, "test#64");
  			Assert.AreEqual ("test1", C.ToString (), "test#65");
  			Assert.IsFalse (C.Unique, "test#66");
  
  			C = Cols [3];
  			Assert.IsTrue (C.AllowDBNull, "test#67");
  			Assert.IsFalse (C.AutoIncrement, "test#68");
  			Assert.AreEqual (0L, C.AutoIncrementSeed, "test#69");
  			Assert.AreEqual (1L, C.AutoIncrementStep, "test#70");
  			Assert.AreEqual ("test2", C.Caption, "test#71");
  			Assert.AreEqual ("Element", C.ColumnMapping.ToString (), "test#72");
  			Assert.AreEqual ("test2", C.ColumnName, "test#73");
  			Assert.IsNull (C.Container, "test#74");
  			Assert.AreEqual (typeof (string), C.DataType, "test#75");
  			Assert.AreEqual (DBNull.Value, C.DefaultValue, "test#76");
  			Assert.IsFalse (C.DesignMode, "test#77");
  			Assert.AreEqual ("Column1 + Column2", C.Expression, "test#78");
  			Assert.AreEqual (0, C.ExtendedProperties.Count, "test#79");
  			Assert.AreEqual (-1, C.MaxLength, "test#80");
  			Assert.AreEqual ("", C.Namespace, "test#81");
  			Assert.AreEqual (3, C.Ordinal, "test#82");
  			Assert.AreEqual ("", C.Prefix, "test#83");
  			Assert.IsTrue (C.ReadOnly, "test#84");
  			Assert.IsNull (C.Site, "test#85");
  			Assert.AreEqual ("test_table", C.Table.TableName, "test#86");
  			Assert.AreEqual ("test2 + Column1 + Column2", C.ToString (), "test#87");
  			Assert.IsFalse (C.Unique, "test#88"); 
  
  			C = new DataColumn ("test3", typeof (int));
  			Cols.Add (C);
  
  			C = Cols [4];
  			Assert.IsTrue (C.AllowDBNull, "test#89");
  			Assert.IsFalse (C.AutoIncrement, "test#90");
  			Assert.AreEqual (0L, C.AutoIncrementSeed, "test#91");
  			Assert.AreEqual (1L, C.AutoIncrementStep, "test#92");
  			Assert.AreEqual ("test3", C.Caption, "test#93");
  			Assert.AreEqual ("Element", C.ColumnMapping.ToString (), "test#94");
  			Assert.AreEqual ("test3", C.ColumnName, "test#95");
  			Assert.IsNull (C.Container, "test#96");
  			Assert.AreEqual (typeof (int), C.DataType, "test#97");
  			Assert.AreEqual (DBNull.Value, C.DefaultValue, "test#98");
  			Assert.IsFalse (C.DesignMode, "test#99");
  			Assert.AreEqual ("", C.Expression, "test#100");
  			Assert.AreEqual (0, C.ExtendedProperties.Count, "test#101");
  			Assert.AreEqual (-1, C.MaxLength, "test#102");
  			Assert.AreEqual ("", C.Namespace, "test#103");
  			Assert.AreEqual (4, C.Ordinal, "test#104");
  			Assert.AreEqual ("", C.Prefix, "test#105");
  			Assert.IsFalse (C.ReadOnly, "test#106");
  			Assert.IsNull (C.Site, "test#107");
  			Assert.AreEqual ("test_table", C.Table.TableName, "test#108");
  			Assert.AreEqual ("test3", C.ToString (), "test#109");
  			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 ()
  		{
  			DataTable Table = new DataTable ("test_table");
  
gt: 			DataTable Table2 = new DataTable ("test_table2");