Standardized Mainsoft ConstraintCollection tests.
authorEyal Alalouf <eyala@mainsoft.com>
Sun, 29 May 2005 10:35:17 +0000 (10:35 -0000)
committerEyal Alalouf <eyala@mainsoft.com>
Sun, 29 May 2005 10:35:17 +0000 (10:35 -0000)
svn path=/trunk/mcs/; revision=45156

mcs/class/System.Data/ChangeLog
mcs/class/System.Data/System.Data_test.dll.sources
mcs/class/System.Data/Test/ChangeLog
mcs/class/System.Data/Test/System.Data.Test.Utils/ChangeLog [new file with mode: 0644]
mcs/class/System.Data/Test/System.Data.Test.Utils/DataProvider.cs [new file with mode: 0644]
mcs/class/System.Data/Test/System.Data/ChangeLog
mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs [new file with mode: 0644]

index ca796d90acc51c2d922bde6f37028a5cd228533c..59c446bdd71181e008e512593f2bc0a3968d881d 100644 (file)
@@ -1,3 +1,6 @@
+2005-05-29 Eyal Alaluf <eyala@mainsoft.com>
+       * System.Data_tests.dll.sources: Unified Mainsoft ConstraintCollection tests into one test in Test/System.Data
+
 2005-05-25 Umadevi S <sumadevi@novell.com>
        * System.Data.dll.sources : Added DbException.cs, SqlClientMetaDataCollectionNames.cs
 
index c5af598e8c721ccde571f8a51a3a86bba479a386..547dcabf4cd40e005de1f5cf497efa9c9ea6b0b6 100644 (file)
@@ -1,3 +1,4 @@
+System.Data.Test.Utils/DataProvider.cs
 System.Data.SqlTypes/SqlBinaryTest.cs
 System.Data.SqlTypes/SqlBooleanTest.cs
 System.Data.SqlTypes/SqlByteTest.cs
@@ -14,6 +15,7 @@ System.Data.SqlTypes/SqlStringTest.cs
 System.Xml/XmlDataDocumentTest.cs
 System.Xml/XmlDataDocumentTest2.cs
 System.Data/ConstraintCollectionTest.cs
+System.Data/ConstraintCollectionTest2.cs
 System.Data/ConstraintTest.cs
 System.Data/DataColumnCollectionTest.cs
 System.Data/DataColumnTest.cs
@@ -59,20 +61,6 @@ System.Data.Tests.Mainsoft/GHTUtils/GHTValueGen.cs
 System.Data.Tests.Mainsoft/GHTUtils/HttpClientBase.cs
 System.Data.Tests.Mainsoft/GHTUtils/ObjectTester.cs
 System.Data.Tests.Mainsoft/GHTUtils/XmlUtils.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_add_CollectionChanged_C.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_CanRemove_C.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_Clear.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_CollectionChanged.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_Contains_S.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_CopyTo_AI.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_Count.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_GetEnumerator.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_IndexOf_C.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_IndexOf_S.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_IsReadOnly.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_IsSynchronized.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_Remove_C.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintCollection/ConstraintCollection_Remove_S.cs
 System.Data.Tests.Mainsoft/System.Data/ConstraintException/ConstraintException_Generate.cs
 System.Data.Tests.Mainsoft/System.Data/DataColumn/DataColumn_AllowDBNull.cs
 System.Data.Tests.Mainsoft/System.Data/DataColumn/DataColumn_AutoIncrement.cs
index fc7299b4dda0d669728119405196c4e8f6b1a007..ffab7db575c390635c38159a58df3cdd4f2f32ea 100644 (file)
@@ -1,3 +1,6 @@
+2005-05-26  Eyal Alaluf <eyala@mainsoft.com>
+       * Added System.Data.Test.Utils - Keeps utilities comon for all tests
+
 2005-02-15  Sureshkumar T  <tsureshkumar@novell.com>
 
        * MySqlTestBed.cs: fix for namespace collision MonoTests.System &
diff --git a/mcs/class/System.Data/Test/System.Data.Test.Utils/ChangeLog b/mcs/class/System.Data/Test/System.Data.Test.Utils/ChangeLog
new file mode 100644 (file)
index 0000000..1976974
--- /dev/null
@@ -0,0 +1,2 @@
+2005-05-26  Eyal Alaluf <eyala@mainsoft.com>
+       * DataProvider.cs: Utiltilty class for creating different types of DataTables.
diff --git a/mcs/class/System.Data/Test/System.Data.Test.Utils/DataProvider.cs b/mcs/class/System.Data/Test/System.Data.Test.Utils/DataProvider.cs
new file mode 100644 (file)
index 0000000..ee513b3
--- /dev/null
@@ -0,0 +1,193 @@
+// Authors:
+//   Rafael Mizrahi   <rafim@mainsoft.com>
+//   Erez Lotan       <erezl@mainsoft.com>
+//   Oren Gurfinkel   <oreng@mainsoft.com>
+//   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 System;
+using System.Data;
+using System.Data.OleDb ;
+using System.IO;
+using System.Collections;
+
+// Provide All Data required by the diffderent tests e.g.DataTable, DataRow ...
+namespace MonoTests.System.Data.Test.Utils
+{
+       public class DataProvider
+       {
+               #region Constatntas
+
+               #region Private
+               //A string containing all printable charachters.
+               private const string SAMPLE_STRING = "abcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()_+-=[]\\|;:,./<>? ";
+               #endregion
+
+               #endregion
+
+               public static DataTable CreateChildDataTable()
+               {
+                       DataTable dtChild = new DataTable("Child");
+                       dtChild.Columns.Add("ParentId",typeof(int));
+                       dtChild.Columns.Add("ChildId",typeof(int));
+                       dtChild.Columns.Add("String1",typeof(string));
+                       dtChild.Columns.Add("String2",typeof(string));
+                       dtChild.Columns.Add("ChildDateTime",typeof(DateTime));
+                       dtChild.Columns.Add("ChildDouble",typeof(double));
+
+                       dtChild.Rows.Add(new object[] {1,1,"1-String1","1-String2",new DateTime(2000,1,1,0,0,0,0),1.534});
+                       dtChild.Rows.Add(new object[] {1,2,"2-String1","2-String2",DateTime.MaxValue ,-1.534});
+                       dtChild.Rows.Add(new object[] {1,3,"3-String1","3-String2",DateTime.MinValue,double.MaxValue/10000});
+                       dtChild.Rows.Add(new object[] {2,1,"1-String1","1-String2",new DateTime(1973,6,20,0,0,0,0),double.MinValue*10000});
+                       dtChild.Rows.Add(new object[] {2,2,"2-String1","2-String2",new DateTime(2008,12,1,13,59,59,59),0.45});
+                       dtChild.Rows.Add(new object[] {2,3,"3-String1","3-String2",new DateTime(2003,1,1,1,1,1,1),0.55});
+                       dtChild.Rows.Add(new object[] {5,1,"1-String1","1-String2",new DateTime(2002,1,1,1,1,1,1),0});
+                       dtChild.Rows.Add(new object[] {5,2,"2-String1","2-String2",new DateTime(2001,1,1,1,1,1,1),10});
+                       dtChild.Rows.Add(new object[] {5,3,"3-String1","3-String2",new DateTime(2000,1,1,1,1,1,1),20});
+                       dtChild.Rows.Add(new object[] {6,1,"1-String1","1-String2",new DateTime(2000,1,1,1,1,1,0),25});
+                       dtChild.Rows.Add(new object[] {6,2,"2-String1","2-String2",new DateTime(2000,1,1,1,1,0,0),30});
+                       dtChild.Rows.Add(new object[] {6,3,"3-String1","3-String2",new DateTime(2000,1,1,0,0,0,0),35});
+                       dtChild.AcceptChanges();
+                       return dtChild;
+               }
+
+               public static DataTable CreateParentDataTable()
+               {
+                       DataTable dtParent = new DataTable("Parent");
+
+                       dtParent.Columns.Add("ParentId",typeof(int));
+                       dtParent.Columns.Add("String1",typeof(string));
+                       dtParent.Columns.Add("String2",typeof(string));
+
+                       dtParent.Columns.Add("ParentDateTime",typeof(DateTime));
+                       dtParent.Columns.Add("ParentDouble",typeof(double));
+                       dtParent.Columns.Add("ParentBool",typeof(bool));
+
+                       dtParent.Rows.Add(new object[] {1,"1-String1","1-String2",new DateTime(2005,1,1,0,0,0,0),1.534,true});
+                       dtParent.Rows.Add(new object[] {2,"2-String1","2-String2",new DateTime(2004,1,1,0,0,0,1),-1.534,true});
+                       dtParent.Rows.Add(new object[] {3,"3-String1","3-String2",new DateTime(2003,1,1,0,0,1,0),double.MinValue*10000,false});
+                       dtParent.Rows.Add(new object[] {4,"4-String1","4-String2",new DateTime(2002,1,1,0,1,0,0),double.MaxValue/10000,true});
+                       dtParent.Rows.Add(new object[] {5,"5-String1","5-String2",new DateTime(2001,1,1,1,0,0,0),0.755,true});
+                       dtParent.Rows.Add(new object[] {6,"6-String1","6-String2",new DateTime(2000,1,1,0,0,0,0),0.001,false});
+                       dtParent.AcceptChanges();
+                       return dtParent;
+               }
+
+               //This method replace the DataSet GetXmlSchema method
+               //used to compare DataSets
+               //Created by Ofer (13-Nov-03) becuase DataSet GetXmlSchema method is not yet implemented in java 
+               public static string GetDSSchema(DataSet ds)
+               {
+                       string strSchema = "DataSet Name=" + ds.DataSetName + "\n"; 
+                       //Get relations
+                       foreach (DataRelation dl in ds.Relations)
+                       {
+                               strSchema += "\t" + "DataRelation Name=" + dl.RelationName ;
+                               foreach (DataColumn dc in dl.ParentColumns)
+                                       strSchema += "\t" + "ParentColummn=" +  dc.ColumnName ;
+                               foreach (DataColumn dc in dl.ChildColumns )
+                                       strSchema += "\t" + "ChildColumn=" +  dc.ColumnName ;
+                               strSchema += "\n";
+                       }
+                       //Get teables
+                       foreach (DataTable dt in ds.Tables)
+                       {
+                               strSchema += "Table=" + dt.TableName + "\t";
+                               //Get Constraints  
+                               strSchema += "Constraints =";
+                               foreach (Constraint cs in dt.Constraints )
+                                       strSchema += cs.GetType().Name + ", ";
+                               strSchema += "\n";
+                               //Get PrimaryKey Columns
+                               strSchema += "PrimaryKey Columns index:=";
+                               foreach (DataColumn dc in dt.PrimaryKey)
+                                       strSchema += dc.Ordinal + ", ";
+                               strSchema += "\n";
+                               //Get Columns
+                               foreach (DataColumn dc in dt.Columns)
+                               {
+                                       strSchema += "ColumnName=" + dc.ColumnName + "\t" +
+                                               "ColumnType=" + dc.DataType.Name + "\t" +
+                                               "AllowDBNull=" + dc.AllowDBNull.ToString() + "\t" +
+                                               "DefaultValue=" + dc.DefaultValue.ToString() + "\t" +
+                                               "Unique=" + dc.Unique.ToString() + "\t" +
+                                               "ReadOnly=" + dc.ReadOnly.ToString() + "\n" ;
+                               }
+                               strSchema += "\n";
+                       }
+                       return strSchema;
+               }
+
+               public static DataTable CreateUniqueConstraint()
+               {
+                       DataTable dt = DataProvider.CreateParentDataTable();
+                       return CreateUniqueConstraint(dt);
+               }
+
+               public static DataTable CreateUniqueConstraint(DataTable dt)
+               {
+                       Constraint con = new UniqueConstraint(dt.Columns["ParentId"]);
+                       dt.Constraints.Add(con);
+                       return dt;
+               }
+
+               public static void TryToBreakUniqueConstraint()
+               {
+                       //Create the constraint
+                       DataTable dt =  CreateUniqueConstraint();
+                       //Try to violate the constraint
+
+                       DataRow dr1 = dt.NewRow();
+                       dr1[0] = 1;
+                       dt.Rows.Add(dr1);
+               }
+
+               public static DataSet CreateForigenConstraint()
+               {
+                       DataTable parent = DataProvider.CreateParentDataTable();
+                       DataTable child = DataProvider.CreateChildDataTable(); 
+                       DataSet ds = new DataSet();
+                       ds.Tables.Add(parent); 
+                       ds.Tables.Add(child);
+
+                       Constraint con1 = new ForeignKeyConstraint(parent.Columns[0],child.Columns[0]);
+                       child.Constraints.Add(con1);
+
+                       return ds;
+               }
+
+               public static void TryToBreakForigenConstraint()
+               {
+                       DataSet ds = CreateForigenConstraint();
+                       //Code to break:
+
+                       DataRow dr =  ds.Tables[1].NewRow();
+                       dr[0]=7;
+                       ds.Tables[1].Rows.Add(dr);
+
+                       ds.AcceptChanges();
+                       ds.EnforceConstraints=true;
+               }
+       } 
+}
index c43bfe1a62b20218efb8d36463ce4c090f9a72ab..d39456b4821d4137fe3ccb10867652a3ab2e24bc 100644 (file)
@@ -1,3 +1,6 @@
+2005-05-29  Eyal Alaluf <eyala@mainsoft.com>
+       * ConstraintCollectionTest2.cs - New file containing Mainsoft ConstraintCollection tests.
+
 2005-05-25  Sureshkumar T  <tsureshkumar@novell.com>
 
        * DataTableLoadRowTest.cs: Added  additional cases for
diff --git a/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs
new file mode 100644 (file)
index 0000000..3731b64
--- /dev/null
@@ -0,0 +1,280 @@
+// Authors:
+//   Rafael Mizrahi   <rafim@mainsoft.com>
+//   Erez Lotan       <erezl@mainsoft.com>
+//   Oren Gurfinkel   <oreng@mainsoft.com>
+//   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 MonoTests.System.Data.Test.Utils;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+
+namespace MonoTests.System.Data
+{
+       [TestFixture] public class ConstraintCollectionTest2
+       {
+               private bool CollectionChangedFlag = false;
+
+               [Test] public void CanRemove_ParentForeign()
+               {
+                       DataSet ds = DataProvider.CreateForigenConstraint();
+                       Assert.AreEqual(false, ds.Tables["parent"].Constraints.CanRemove(ds.Tables["parent"].Constraints[0]), "CN1");
+               }
+
+               [Test] public void CanRemove_ChildForeign()
+               {
+                       DataSet ds = DataProvider.CreateForigenConstraint();
+                       Assert.AreEqual(true, ds.Tables["child"].Constraints.CanRemove(ds.Tables["child"].Constraints[0]), "CN2");
+               }
+
+               [Test] public void CanRemove_ParentAndChildForeign()
+               {
+                       DataSet ds = DataProvider.CreateForigenConstraint();
+                       //remove the forigen and ask about the unique
+                       ds.Tables["child"].Constraints.Remove(ds.Tables["child"].Constraints[0]);
+                       Assert.AreEqual(true, ds.Tables["parent"].Constraints.CanRemove(ds.Tables["parent"].Constraints[0]), "CN3");
+               }
+
+               // FIXME. This test isn't complete.
+               public void CanRemove_Unique()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       //remove the forigen and ask about the unique
+                       dt.Constraints.Remove(dt.Constraints[0]);
+                       Assert.AreEqual(true, dt.Constraints.CanRemove(dt.Constraints[0]), "CN4");
+               }
+
+               [Test] public void Clear_Foreign()
+               {
+                       DataSet ds = DataProvider.CreateForigenConstraint();
+                       foreach(DataTable dt in ds.Tables)
+                       {
+                               dt.Constraints.Clear();
+                       }
+                       Assert.AreEqual(0, ds.Tables[0].Constraints.Count, "CN5");
+                       Assert.AreEqual(0, ds.Tables[0].Constraints.Count, "CN6");
+
+               }
+
+               [Test] public void Clear_Unique()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       int rowsCount = dt.Rows.Count;
+                       dt.Constraints.Clear();
+                       DataRow dr = dt.NewRow();
+                       dr[0] = 1;
+                       dt.Rows.Add(dr);
+                       Assert.AreEqual(rowsCount+1, dt.Rows.Count, "CN7"); //Just checking that no expection ocuured
+               }
+
+               [Test] public void CollectionChanged()
+               {
+                       DataTable dt = DataProvider.CreateParentDataTable();
+                       CollectionChangedFlag = false;
+                       dt.Constraints.CollectionChanged += new CollectionChangeEventHandler(Constraints_CollectionChangedHandler);     
+                       dt = DataProvider.CreateUniqueConstraint(dt);
+                       Assert.AreEqual(true, CollectionChangedFlag, "CN8"); 
+               }
+
+               [Test] public void Contains_ByName()
+               {
+                       DataSet ds =  DataProvider.CreateForigenConstraint();
+        
+                       //changing the constraints's name
+
+                       ds.Tables["child"].Constraints[0].ConstraintName = "name1";
+                       ds.Tables["parent"].Constraints[0].ConstraintName = "name2";
+
+
+                       Assert.AreEqual(true, ds.Tables["child"].Constraints.Contains("name1"), "CN9");
+                       Assert.AreEqual(false, ds.Tables["child"].Constraints.Contains("xxx"), "CN10");
+                       Assert.AreEqual(true, ds.Tables["parent"].Constraints.Contains("name2"), "CN11");
+                       Assert.AreEqual(false, ds.Tables["parent"].Constraints.Contains("xxx"), "CN12");
+
+               }
+
+               [Test] public void CopyTo()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints.Add("constraint2",dt.Columns["String1"],true);
+
+                       object[] ar = new object[2];
+
+                       dt.Constraints.CopyTo(ar,0);
+                       Assert.AreEqual(2, ar.Length, "CN13");
+               }
+
+               [Test] public void Count()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       Assert.AreEqual(1, dt.Constraints.Count, "CN14");
+
+                       //Add
+
+                       dt.Constraints.Add("constraint2",dt.Columns["String1"],false);
+                       Assert.AreEqual(2, dt.Constraints.Count, "CN15");
+
+                       //Remove
+
+                       dt.Constraints.Remove("constraint2");
+                       Assert.AreEqual(1, dt.Constraints.Count, "CN16");
+               }
+
+               [Test] public void GetEnumerator()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints.Add("constraint2",dt.Columns["String1"],false);
+
+                       int counter=0;
+                       IEnumerator myEnumerator = dt.Constraints.GetEnumerator();
+                       while (myEnumerator.MoveNext())
+                       {
+                               counter++;
+
+                       }
+                       Assert.AreEqual(2, counter, "CN17");
+               }
+
+               [Test] public void IndexOf()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       Assert.AreEqual(0, dt.Constraints.IndexOf(dt.Constraints[0]), "CN18");
+
+                       //Add new constraint
+                       Constraint con = new UniqueConstraint(dt.Columns["String1"],false);
+
+                       dt.Constraints.Add(con);
+                       Assert.AreEqual(1, dt.Constraints.IndexOf(con), "CN19");
+
+                       //Remove it and try to look for it 
+
+                       dt.Constraints.Remove(con);
+                       Assert.AreEqual(-1, dt.Constraints.IndexOf(con), "CN20");
+
+               }
+
+               [Test] public void IndexOf_ByName()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints[0].ConstraintName="name1";
+                       Assert.AreEqual(0, dt.Constraints.IndexOf("name1"), "CN21");
+
+                       //Add new constraint
+                       Constraint con = new UniqueConstraint(dt.Columns["String1"],false);
+                       con.ConstraintName="name2";
+
+                       dt.Constraints.Add(con);
+                       Assert.AreEqual(1, dt.Constraints.IndexOf("name2"), "CN22");
+
+                       //Remove it and try to look for it 
+
+                       dt.Constraints.Remove(con);
+                       Assert.AreEqual(-1, dt.Constraints.IndexOf("name2"), "CN23");
+
+               }
+
+               [Test] public void IsReadOnly()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       Assert.AreEqual(false, dt.Constraints.IsReadOnly, "CN24"); 
+               }
+
+               [Test] public void IsSynchronized()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       Assert.AreEqual(false, dt.Constraints.IsSynchronized, "CN25");
+        
+                       ConstraintCollection col = (ConstraintCollection)dt.Constraints.SyncRoot;
+
+       //              lock(dt.Constraints.SyncRoot)
+       //              {
+                       //      Assert.AreEqual(true, col.IsSynchronized, "CN26");
+
+                       //}
+               }
+
+               [Test] public void Remove()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints.Remove(dt.Constraints[0]);
+                       Assert.AreEqual(0, dt.Constraints.Count, "CN27");
+               }
+
+               [Test] public void Remove_ByNameSimple()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints[0].ConstraintName = "constraint1";
+                       dt.Constraints.Remove("constraint1");
+                       Assert.AreEqual(0, dt.Constraints.Count, "CN28");
+               }
+
+               [Test] public void Remove_ByNameWithAdd()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       dt.Constraints[0].ConstraintName = "constraint1";
+                       Constraint con = new UniqueConstraint(dt.Columns["String1"],false);
+                       dt.Constraints.Add(con);
+                       dt.Constraints.Remove(con);
+
+                       Assert.AreEqual(1, dt.Constraints.Count, "CN29");
+                       Assert.AreEqual("constraint1", dt.Constraints[0].ConstraintName, "CN30");
+               }
+
+               [Test] public void Remove_CollectionChangedEvent()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       CollectionChangedFlag = false;
+                       dt.Constraints.CollectionChanged += new CollectionChangeEventHandler(Constraints_CollectionChangedHandler);
+                       dt.Constraints.Remove(dt.Constraints[0]);
+                       Assert.AreEqual(true, CollectionChangedFlag, "CN31"); //Checking that event has raised
+               }
+
+               [Test] public void Remove_ByNameCollectionChangedEvent()
+               {
+                       DataTable dt = DataProvider.CreateUniqueConstraint();
+                       CollectionChangedFlag = false;
+                       dt.Constraints.CollectionChanged += new CollectionChangeEventHandler(Constraints_CollectionChangedHandler);
+                       dt.Constraints.Remove("constraint1");
+                       Assert.AreEqual(true, CollectionChangedFlag, "CN32"); //Checking that event has raised
+
+               }
+
+               [Test] public void add_CollectionChanged()
+               {
+                       DataTable dt = DataProvider.CreateParentDataTable();
+                       CollectionChangedFlag = false;
+                       dt.Constraints.CollectionChanged += new CollectionChangeEventHandler(Constraints_CollectionChangedHandler);     
+                       dt = DataProvider.CreateUniqueConstraint(dt);
+                       Assert.AreEqual(true, CollectionChangedFlag, "CN33"); 
+               }
+
+               private void Constraints_CollectionChangedHandler(object sender, CollectionChangeEventArgs e)
+               {
+                       CollectionChangedFlag = true;
+               }
+       }
+}