diff options
author | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2006-01-02 15:45:40 +0300 |
---|---|---|
committer | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2006-01-02 15:45:40 +0300 |
commit | 6f68de6cab8d2859702795001bc6ae7535d20fc8 (patch) | |
tree | 0cfd03efcba322b93645c27a12a4c875fb4399da /mcs/class/System.Data/Test | |
parent | 857f2b5d74c8142a861681663d9c1ae9f03725fe (diff) |
Added a bulk of tests from Mainsoft repository.
svn path=/trunk/mcs/; revision=54952
Diffstat (limited to 'mcs/class/System.Data/Test')
18 files changed, 4906 insertions, 79 deletions
diff --git a/mcs/class/System.Data/Test/ChangeLog b/mcs/class/System.Data/Test/ChangeLog index a3792cc95e4..d8b422745de 100644 --- a/mcs/class/System.Data/Test/ChangeLog +++ b/mcs/class/System.Data/Test/ChangeLog @@ -1,3 +1,7 @@ +2006-01-02 Boris Kirzner <borisk@mainsoft.com> + + * System.Data.Test.vmwcsproj: added new tests to TARGET_JVM project file. + 2005-12-12 Konstantin Triger <kostat@mainsoft.com> * System.Data.Test.vmwcsproj: add NET_1_1 define. diff --git a/mcs/class/System.Data/Test/System.Data.Test.vmwcsproj b/mcs/class/System.Data/Test/System.Data.Test.vmwcsproj index 0bcbc7a85f5..1e47ac9a467 100644 --- a/mcs/class/System.Data/Test/System.Data.Test.vmwcsproj +++ b/mcs/class/System.Data/Test/System.Data.Test.vmwcsproj @@ -40,6 +40,7 @@ <File RelPath="System.Data\DataSetReadXmlTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\DataSetTest.cs" SubType="Component" BuildAction="Compile"/>
<File RelPath="System.Data\DataSetTest2.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Data\DataSetTypedDataSetTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\DataTableCollectionTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\DataTableCollectionTest2.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\DataTableLoadRowTest.cs" SubType="Code" BuildAction="Compile"/>
@@ -57,6 +58,7 @@ <File RelPath="System.Data\ForeignKeyConstraintTest2.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\InRowChangingEventExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\InvalidConstraintExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Data\MissingPrimaryKeyExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\NoNullAllowedExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\own_schema.xsd" BuildAction="Content"/>
<File RelPath="System.Data\ReadOnlyExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
@@ -67,8 +69,10 @@ <File RelPath="System.Data\store3.xsd" BuildAction="Content"/>
<File RelPath="System.Data\store4.xsd" BuildAction="Content"/>
<File RelPath="System.Data\SyntaxErrorExceptionTest.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Data\TypedDataSet.xml" BuildAction="Content"/>
<File RelPath="System.Data\UniqueConstraintTest.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\UniqueConstraintTest2.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Data\VersionNotFoundException.cs" SubType="Code" BuildAction="Compile"/>
<File RelPath="System.Data\schemas\ChangeLog" BuildAction="None"/>
<File RelPath="System.Data\schemas\test001.xsd" BuildAction="Content"/>
<File RelPath="System.Data\schemas\test002.xsd" BuildAction="Content"/>
diff --git a/mcs/class/System.Data/Test/System.Data/ChangeLog b/mcs/class/System.Data/Test/System.Data/ChangeLog index f5ed498cd2a..477be04a211 100644 --- a/mcs/class/System.Data/Test/System.Data/ChangeLog +++ b/mcs/class/System.Data/Test/System.Data/ChangeLog @@ -1,3 +1,13 @@ +2006-01-02 Boris Kirzner <borisk@mainsoft.com> + * DataTableCollectionTest2.cs, DataColumnTest2.cs, + DataViewTest2.cs, DataRowCollectionTest2.cs, DataTableTest2.cs, + DataRelationCollectionTest2.cs, ForeignKeyConstraintTest2.cs, + DataSetTest2.cs, ConstraintCollectionTest2.cs, DataRowTest2.cs, + DataColumnCollectionTest2.cs: new tests from Mainsoft repository. + * DataSetTypedDataSetTest.cs, VersionNotFoundException.cs, + MissingPrimaryKeyExceptionTest.cs: added files with new tests. + * TypedDataSet.xml - new xml file (for TypeDataSetTest.cs). + 2005-12-20 Senganal T <tsenganal@novell.com> * DataColumnTest.cs : added testcase for #77025 diff --git a/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs index 8ba87d69339..a857296a7e9 100644 --- a/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/ConstraintCollectionTest2.cs @@ -276,5 +276,220 @@ namespace MonoTests.System.Data { CollectionChangedFlag = true; } + + public delegate void testExceptionMethodCallback(); + + [Test] + public void Add_Constraint()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+ Assert.AreEqual(1,dt.Constraints.Count,"ccac#1");
+ Assert.AreEqual("Constraint1",dt.Constraints[0].ConstraintName,"ccac#2");
+
+ DataSet ds = DataProvider.CreateForigenConstraint();
+ Assert.AreEqual(1,ds.Tables[1].Constraints.Count,"ccac#3");
+ Assert.AreEqual(1,ds.Tables[0].Constraints.Count,"ccac#4");
+
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new ConstraintException());
+ TestException( new testExceptionMethodCallback(DataProvider.TryToBreakUniqueConstraint),arr);
+
+ arr = new ArrayList(1);
+ arr.Add(new InvalidConstraintException());
+ TestException( new testExceptionMethodCallback(DataProvider.TryToBreakForigenConstraint),arr);
+ }
+
+ private void TestException(testExceptionMethodCallback dlg,IList exceptionList)
+ {
+ try {
+ dlg();
+ Assert.Fail("ccac#A", ((Exception)exceptionList[0]).ToString());
+ }
+ catch(Exception ex) {
+ foreach(Exception expectedEx in exceptionList)
+ if ( (expectedEx.GetType()) == (ex.GetType()) )
+ return;
+ Assert.Fail("ccac#B");
+ }
+ } + + [Test] + public void Add_SDB1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Constraints.Add("UniqueConstraint",dt.Columns["ParentId"],true);
+ Assert.AreEqual(1,dt.Constraints.Count,1);
+ Assert.AreEqual("UniqueConstraint",dt.Constraints[0].ConstraintName,"CN34");
+ }
+ + [Test] + public void Add_SDB2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Constraints.Add("UniqueConstraint",dt.Columns["ParentId"],false);
+ Assert.AreEqual(1,dt.Constraints.Count,"CN34");
+ Assert.AreEqual("UniqueConstraint",dt.Constraints[0].ConstraintName,"CN35");
+ }
+ + [Test] + public void Add_SDB3()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Constraints.Add("UniqueConstraint",dt.Columns["ParentId"],true);
+ //Break the constraint
+
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new ConstraintException());
+ TestException( new testExceptionMethodCallback(DataProvider.TryToBreakUniqueConstraint),arr);
+
+ }
+ + [Test] + [ExpectedException(typeof(ConstraintException))] + public void Add_SDB4()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Constraints.Add("UniqueConstraint",dt.Columns["ParentId"],false);
+ //Break the constraint --> but we shouldn't get the excption --> wrong assumpation
+ //TODO:check the right thing
+ DataProvider.TryToBreakUniqueConstraint();
+ Assert.AreEqual(2,dt.Select("ParentId=1").Length,"CN36");
+ } + + [Test] + public void Add_Constraint_Column_Column()
+ {
+ DataTable parent = DataProvider.CreateParentDataTable();
+ DataTable child = DataProvider.CreateChildDataTable();
+
+ child.Constraints.Add("ForigenConstraint",parent.Columns[0],child.Columns[0]);
+
+ Assert.AreEqual(1,parent.Constraints.Count,"ccaccc#1");
+ Assert.AreEqual(1,child.Constraints.Count,"ccaccc#2");
+ Assert.AreEqual("ForigenConstraint",child.Constraints[0].ConstraintName,"ccaccc#3");
+
+ parent = DataProvider.CreateParentDataTable();
+ child = DataProvider.CreateChildDataTable();
+
+ child.Constraints.Add("ForigenConstraint",parent.Columns[0],child.Columns[0]);
+
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new InvalidConstraintException());
+ TestException( new testExceptionMethodCallback(DataProvider.TryToBreakForigenConstraint),arr);
+
+ Assert.AreEqual(1,parent.Constraints.Count,"ccaccc#4");
+ Assert.AreEqual(1,child.Constraints.Count,"ccaccc#5");
+ } + + [Test] + public void AddRange_C1()
+ {
+ DataTable dt = new DataTable();
+ dt.Constraints.AddRange(null);
+ Assert.AreEqual(0,dt.Constraints.Count,"ccarc#1");
+ }
+
+ [Test] + public void AddRange_C2()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(DataProvider.CreateParentDataTable());
+ ds.Tables.Add(DataProvider.CreateChildDataTable());
+ ds.Tables[1].Constraints.AddRange(GetConstraintArray(ds)); //Cuz foreign key belongs to child table
+ Assert.AreEqual(2,ds.Tables[1].Constraints.Count,"ccarc#2");
+ Assert.AreEqual(1,ds.Tables[0].Constraints.Count,"ccarc#3");
+ }
+ [Test] + [ExpectedException(typeof(ArgumentException))] + public void AddRange_C3()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(DataProvider.CreateParentDataTable());
+ ds.Tables.Add(DataProvider.CreateChildDataTable());
+ Constraint badConstraint = new UniqueConstraint(ds.Tables[0].Columns[0]);
+
+ ds.Tables[1].Constraints.AddRange(new Constraint[] {badConstraint}); //Cuz foreign key belongs to child table
+ }
+ + [Test] + public void AddRange_C4()
+ {
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new ArgumentException());
+ TestException(new testExceptionMethodCallback(AddRange_C3),arr);
+ }
+
+ private Constraint[] GetConstraintArray(DataSet ds)
+ {
+ DataTable parent = ds.Tables[0];
+ DataTable child = ds.Tables[1];
+ Constraint[] constArray = new Constraint[2];
+
+ //Create unique
+ constArray[0] = new UniqueConstraint("Unique1",child.Columns["ChildDouble"]);
+ //Create foreign
+ constArray[1] = new ForeignKeyConstraint(parent.Columns[0],child.Columns[1]);
+
+ return constArray;
+ }
+
+ [Test]
+ public void Item()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+ dt.Constraints[0].ConstraintName = "constraint1";
+ Assert.AreEqual("constraint1",dt.Constraints[0].ConstraintName,"cci#1");
+ Assert.AreEqual("constraint1",dt.Constraints["constraint1"].ConstraintName,"cci#2");
+
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new IndexOutOfRangeException());
+ TestException(new testExceptionMethodCallback(Item2),arr);
+ }
+
+ private void Item2()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+ dt.Constraints[1].ConstraintName = "error";
+ }
+
+ private bool collectionChanged=false;
+
+ [Test]
+ private void RemoveAt_Integer()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+ dt.Constraints.RemoveAt(0);
+ Assert.AreEqual(0,dt.Constraints.Count,"ccrai#1");
+
+ dt = DataProvider.CreateUniqueConstraint();
+ Constraint con = new UniqueConstraint(dt.Columns["String1"],false);
+ dt.Constraints[0].ConstraintName = "constraint1";
+ con.ConstraintName="constraint2";
+ dt.Constraints.Add(con);
+ dt.Constraints.RemoveAt(0);
+ Assert.AreEqual(1,dt.Constraints.Count,"ccrai#2");
+ Assert.AreEqual("constraint2",dt.Constraints[0].ConstraintName,"ccrai#3");
+
+ dt = DataProvider.CreateUniqueConstraint();
+ dt.Constraints.CollectionChanged+=new CollectionChangeEventHandler(Constraints_CollectionChanged);
+ dt.Constraints.RemoveAt(0);
+ Assert.AreEqual(true,collectionChanged,"ccrai#4"); //Checking that event has raised
+
+ ArrayList arr = new ArrayList(1);
+ arr.Add(new IndexOutOfRangeException());
+ TestException(new testExceptionMethodCallback(RemoveAt_I),arr);
+ }
+
+ private void Constraints_CollectionChanged(object sender, CollectionChangeEventArgs e)
+ {
+ collectionChanged = true;
+ }
+
+ private void RemoveAt_I()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+ dt.Constraints.RemoveAt(2);
+ }
+ } } diff --git a/mcs/class/System.Data/Test/System.Data/DataColumnCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/DataColumnCollectionTest2.cs index 511c3e6374a..4458d473c8e 100644 --- a/mcs/class/System.Data/Test/System.Data/DataColumnCollectionTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataColumnCollectionTest2.cs @@ -31,6 +31,7 @@ using System; using System.ComponentModel;
using System.Data;
using MonoTests.System.Data.Utils;
+using System.Collections;
namespace MonoTests.System.Data
{
@@ -426,5 +427,345 @@ namespace MonoTests.System.Data Assert.Fail("DCC78: Remove. Wrong exception type. Got:" + exc);
}
}
+
+ [Test]
+ public void Add_DataColumn1()
+ {
+ DataTable dt = new DataTable();
+ DataColumn col = new DataColumn("col1",Type.GetType("System.String"));
+ dt.Columns.Add(col);
+ Assert.AreEqual(1,dt.Columns.Count,"dccadc1#1");
+ Assert.AreEqual("col1",dt.Columns[0].ColumnName,"dccadc1#2");
+ Assert.AreEqual("System.String",dt.Columns[0].DataType.ToString(),"dccadc1#3");
+ }
+
+ [Test]
+ public void Add_DataColumn2()
+ {
+ DataTable dt = new DataTable();
+ DataColumn col = new DataColumn("col1",Type.GetType("System.String"));
+ dt.Columns.Add(col);
+ try
+ {
+ dt.Columns.Add(col);
+ Assert.Fail("dccadc2#1: Add failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccadc2#2: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void Add_DataColumn3()
+ {
+ DataTable dt = new DataTable();
+ DataColumn col = new DataColumn("col1",Type.GetType("System.String"));
+ dt.Columns.Add(col);
+ try
+ {
+ DataColumn col1 = new DataColumn("col1",Type.GetType("System.String"));
+ dt.Columns.Add(col1);
+ Assert.Fail("dccadc3#1: Add failed to throw DuplicateNameExcpeion");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccadc3#2: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void Add_String1()
+ {
+ DataTable dt = new DataTable();
+ dt.Columns.Add("col1");
+ Assert.AreEqual(1,dt.Columns.Count,"dccas1#1");
+ Assert.AreEqual("col1",dt.Columns[0].ColumnName,"dccas1#2");
+
+ }
+
+ [Test]
+ public void Add_String2()
+ {
+ DataTable dt = new DataTable();
+ dt.Columns.Add("col1");
+ try
+ {
+ dt.Columns.Add("col1");
+ Assert.Fail("dccas2#1: Add failed to throw DuplicateNameExcpeion");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccas2#2: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void AddRange_DataColumn1()
+ {
+ DataTable dt = new DataTable();
+ dt.Columns.AddRange(GetDataColumArray());
+ Assert.AreEqual(2,dt.Columns.Count,"dccardc1#1");
+ Assert.AreEqual("col1",dt.Columns[0].ColumnName,"dccardc1#2");
+ Assert.AreEqual("col2",dt.Columns[1].ColumnName,"dccardc1#3");
+ Assert.AreEqual(typeof(int),dt.Columns[0].DataType,"dccardc1#4");
+ Assert.AreEqual(typeof(string),dt.Columns[1].DataType,"dccardc1#5");
+ }
+
+ [Test]
+ public void AddRange_DataColumn2()
+ {
+ DataTable dt = new DataTable();
+ try
+ {
+ dt.Columns.AddRange(GetBadDataColumArray());
+ Assert.Fail("dccardc2#1: AddRange failed to throw DuplicateNameExcpeion");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccardc2#2: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void DataColumnCollection_AddRange_DataColumn3()
+ {
+ DataTable dt = new DataTable();
+ dt.Columns.AddRange(null);
+ }
+
+ private DataColumn[] GetDataColumArray()
+ {
+ DataColumn[] arr = new DataColumn[2];
+
+ arr[0] = new DataColumn("col1",typeof(int));
+ arr[1] = new DataColumn("col2",typeof(string));
+
+ return arr;
+ }
+
+ private DataColumn[] GetBadDataColumArray()
+ {
+ DataColumn[] arr = new DataColumn[2];
+
+ arr[0] = new DataColumn("col1",typeof(int));
+ arr[1] = new DataColumn("col1",typeof(string));
+
+ return arr;
+ }
+
+ [Test]
+ public void Clear1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Columns.Clear();
+ Assert.AreEqual(0,dt.Columns.Count,"dccc1#1");
+ }
+
+ [Test]
+ public void Clear2()
+ {
+ DataSet ds = DataProvider.CreateForigenConstraint();
+
+ try
+ {
+ ds.Tables[0].Columns.Clear();
+ Assert.Fail("dccc2#1: Clear failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccc2#2: Clear. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void Clear3()
+ {
+ DataSet ds = DataProvider.CreateForigenConstraint();
+ ds.Tables[1].Constraints.RemoveAt(0);
+ ds.Tables[0].Constraints.RemoveAt(0);
+ ds.Tables[0].Columns.Clear();
+ ds.Tables[1].Columns.Clear();
+ Assert.AreEqual(0,ds.Tables[0].Columns.Count,"dccc3#1");
+ Assert.AreEqual(0,ds.Tables[1].Columns.Count,"dccc3#2");
+ }
+
+ [Test]
+ public void GetEnumerator()
+ {
+ DataTable dt = DataProvider.CreateUniqueConstraint();
+
+ int counter=0;
+ IEnumerator myEnumerator = dt.Columns.GetEnumerator();
+ while (myEnumerator.MoveNext())
+ {
+ counter++;
+ }
+ Assert.AreEqual(6,counter,"dccge#1");
+
+ try
+ {
+ DataColumn col = (DataColumn)myEnumerator.Current;
+ Assert.Fail("dccc2#1: GetEnumerator failed to throw InvalidOperationException");
+ }
+ catch (InvalidOperationException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccc2#2: GetEnumerator. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void Item()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+
+ Assert.AreEqual("ParentId",dt.Columns["ParentId"].ColumnName,"dcci#1");
+ Assert.AreEqual("ParentId",dt.Columns["parentId"].ColumnName ,"dcci#2");
+ Assert.AreEqual("String1",dt.Columns[1].ColumnName,"dcci#3");
+
+ try
+ {
+ dt.Columns[-1].ColumnName = "error";
+ Assert.Fail("dcci#3: Item failed to throw IndexOutOfRangeException");
+ }
+ catch (IndexOutOfRangeException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dcci#4: Item. Wrong exception type. Got:" + exc);
+ }
+
+ try
+ {
+ dt.Columns[null].ColumnName = "error";
+ Assert.Fail("dcci#5: Item failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dcci#6: Item. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test]
+ public void Remove()
+ {
+ //prepare a DataSet with DataTable to be checked
+ DataTable dtSource = new DataTable();
+ dtSource.Columns.Add("Col_0", typeof(int));
+ dtSource.Columns.Add("Col_1", typeof(int));
+ dtSource.Columns.Add("Col_2", typeof(int));
+ dtSource.Rows.Add(new object[] {0,1,2});
+
+ DataTable dt = null;
+
+ //------Check Remove first column---------
+ dt = dtSource.Clone();
+ dt.ImportRow(dtSource.Rows[0]);
+
+ dt.Columns.Remove(dt.Columns[0].ColumnName);
+ Assert.AreEqual(2,dt.Columns.Count , "dccr#1");
+ Assert.AreEqual(false,dt.Columns.Contains("Col_0"),"dccr#2");
+ Assert.AreEqual(1,dt.Rows[0][0],"dccr#3");
+ Assert.AreEqual(2,dt.Rows[0][1],"dccr#4");
+
+
+
+ //------Check Remove middle column---------
+ dt = dtSource.Clone();
+ dt.ImportRow(dtSource.Rows[0]);
+
+ dt.Columns.Remove(dt.Columns[1].ColumnName);
+ Assert.AreEqual(2,dt.Columns.Count , "dccr#5");
+ Assert.AreEqual(false,dt.Columns.Contains("Col_1"),"dccr#6");
+ Assert.AreEqual(0,dt.Rows[0][0],"dccr#7");
+ Assert.AreEqual(2,dt.Rows[0][1],"dccr#8");
+
+
+ //------Check Remove last column---------
+ dt = dtSource.Clone();
+ dt.ImportRow(dtSource.Rows[0]);
+
+ dt.Columns.Remove(dt.Columns[2].ColumnName);
+
+ Assert.AreEqual(2,dt.Columns.Count , "dccr#9");
+ Assert.AreEqual(false,dt.Columns.Contains("Col_2"),"dccr#10");
+ Assert.AreEqual(0,dt.Rows[0][0],"dccr#11");
+ Assert.AreEqual(1,dt.Rows[0][1],"dccr#12");
+
+
+ //------Check Remove column exception---------
+ dt = dtSource.Clone();
+ dt.ImportRow(dtSource.Rows[0]);
+
+ try
+ {
+ dt.Columns.Remove("NotExist");
+ Assert.Fail("dccr#13: Remove failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccr#14: Remove. Wrong exception type. Got:" + exc);
+ }
+
+ dt.Columns.Clear();
+
+ try
+ {
+ dt.Columns.Remove("Col_0");
+ Assert.Fail("dccr#15: Remove failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccr#16: Remove. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ private bool eventOccured = false;
+
+ [Test]
+ public void RemoveAt_Integer()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Columns.CollectionChanged+=new CollectionChangeEventHandler(Columns_CollectionChanged1);
+ int originalColumnCount = dt.Columns.Count;
+ dt.Columns.RemoveAt(0);
+ Assert.AreEqual(originalColumnCount-1,dt.Columns.Count,"dccrai#1");
+ Assert.AreEqual(true,eventOccured,"dccrai#2");
+
+ try
+ {
+ dt.Columns.RemoveAt(-1);
+ Assert.Fail("dccrai#3: RemoveAt failed to throw IndexOutOfRangeException");
+ }
+ catch (IndexOutOfRangeException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccrai#4: RemoveAt. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ private void Columns_CollectionChanged1(object sender, CollectionChangeEventArgs e)
+ {
+ eventOccured = true;
+ }
}
}
diff --git a/mcs/class/System.Data/Test/System.Data/DataColumnTest2.cs b/mcs/class/System.Data/Test/System.Data/DataColumnTest2.cs index c9045780cf9..c56db7ecd6c 100644 --- a/mcs/class/System.Data/Test/System.Data/DataColumnTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataColumnTest2.cs @@ -29,6 +29,7 @@ using NUnit.Framework; using System; using System.Data; +using MonoTests.System.Data.Utils; namespace MonoTests.System.Data { @@ -488,5 +489,271 @@ namespace MonoTests.System.Data // Ordinal Get Assert.AreEqual((int)3 , dc.Ordinal , "DC54"); } + + [Test]
+ public void Expression()
+ {
+ DataColumn dc;
+ string sExpression = "Tax * 0.59";
+ dc = new DataColumn("ColName",typeof(string));
+
+ Assert.AreEqual(string.Empty, dc.Expression, "dce#1");
+
+ dc.Expression = sExpression;
+
+ Assert.AreEqual(sExpression,dc.Expression, "dce#2");
+ } + + [Test]
+#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Expression_Exceptions()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ try
+ {
+ dt.Columns[0].Unique=true;
+ dt.Columns[0].Expression = "sum(" + dt.Columns[0].ColumnName + ")";
+ Assert.Fail("dccee#1: Expression failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#2: Expression. Wrong exception type. Got:" + exc);
+ }
+
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+ dt1.Columns[0].AutoIncrement=true;
+ dt1.Columns[0].Expression = "sum(" + dt1.Columns[0].ColumnName + ")";
+ Assert.Fail("dccee#3: Expression failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#4: Expression. Wrong exception type. Got:" + exc);
+ }
+
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+ dt1.Constraints.Add(new UniqueConstraint(dt1.Columns[0],false));
+ dt1.Columns[0].Expression = "count(" + dt1.Columns[0].ColumnName + ")";
+ Assert.Fail("dccee#5: Expression failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#6: Expression. Wrong exception type. Got:" + exc);
+ }
+
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+
+ dt1.Columns[0].Expression = "CONVERT(" + dt1.Columns[1].ColumnName + ",'System.Int32')";
+ Assert.Fail("dccee#7: Expression failed to throw FormatException");
+ }
+ catch (FormatException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#8: Expression. Wrong exception type. Got:" + exc);
+ }
+
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+
+ dt1.Columns[0].Expression = "CONVERT(" + dt1.Columns[0].ColumnName + ",'System.DateTime')";
+ Assert.Fail("dccee#9: Expression failed to throw ArgmentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#10: Expression. Wrong exception type. Got:" + exc);
+ }
+
+
+#if !KNOWN_BUG //BUG_NUM:3697
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+
+ dt1.Columns[1].Expression = "CONVERT(" + dt1.Columns[0].ColumnName + ",'System.DateTime')";
+ Assert.Fail("dccee#11: Expression failed to throw InvalidCastException");
+ }
+ catch (InvalidCastException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#12: Expression. Wrong exception type. Got:" + exc);
+ }
+#endif
+
+ try
+ {
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+
+ dt1.Columns[1].Expression = "SUBSTRING(" + dt1.Columns[2].ColumnName + ",60000000000,2)";
+ Assert.Fail("dccee#13: Expression failed to throw OverflowException");
+ }
+ catch (OverflowException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("dccee#14: Expression. Wrong exception type. Got:" + exc);
+ }
+ } + + [Test]
+ public void Expression_Simple()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ //Simple expression --> not aggregate
+ DataColumn dc = new DataColumn("expr",Type.GetType("System.Decimal"));
+ dt.Columns.Add(dc);
+ dt.Columns["expr"].Expression = dt.Columns[0].ColumnName + "*0.52 +" + dt.Columns[0].ColumnName;
+
+ //Check the values
+ //double temp;
+ string temp;
+ string str;
+
+ foreach(DataRow dr in dt.Rows) {
+ str = ( ((int)dr[0])*0.52 + ((int)dr[0])).ToString();
+ if (str.Length > 3)
+ temp = str.Substring(0,4);
+ else
+ temp = str;
+ //Due to bug in GH 4.56 sometimes looks like : 4.56000000000000005
+
+ //temp = Convert.ToDouble(str);
+
+ if (dr["expr"].ToString().Length >3)
+ str = dr["expr"].ToString().Substring(0,4);
+ else
+ str = dr["expr"].ToString();
+
+ if (str == "7.60")
+ str = "7.6";
+
+ Assert.AreEqual(temp,str, "dcse#1");
+ //Compare(Convert.ToDouble(dr["expr"]), temp);
+ }
+ } + + [Test]
+ public void Expression_Aggregate()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ //Simple expression --> aggregate
+ DataColumn dc = new DataColumn("expr",Type.GetType("System.Decimal"));
+ dt.Columns.Add(dc);
+ dt.Columns["expr"].Expression = "sum(" + dt.Columns[0].ColumnName + ") + count(" + dt.Columns[0].ColumnName + ")" ;
+ dt.Columns["expr"].Expression+= " + avg(" + dt.Columns[0].ColumnName + ") + Min(" + dt.Columns[0].ColumnName + ")" ;
+
+
+ //Check the values
+ double temp;
+ string str;
+
+ double sum = Convert.ToDouble(dt.Compute("sum(" + dt.Columns[0].ColumnName + ")",string.Empty));
+ double count = Convert.ToDouble(dt.Compute("count(" + dt.Columns[0].ColumnName + ")",string.Empty));
+ double avg = Convert.ToDouble(dt.Compute("avg(" + dt.Columns[0].ColumnName + ")",string.Empty));
+ double min = Convert.ToDouble(dt.Compute("min(" + dt.Columns[0].ColumnName + ")",string.Empty));
+
+ str = (sum+count+avg+min).ToString();
+ foreach(DataRow dr in dt.Rows)
+ {
+ if (str.Length > 3)
+ {
+ temp = Convert.ToDouble(str.Substring(0,4));
+ }
+ else
+ {
+ temp = Convert.ToDouble(str);
+ }
+
+ Assert.AreEqual(temp, Convert.ToDouble(dr["expr"]), "dcea#1");
+ }
+ } + + [Test]
+ public void Expression_AggregateRelation()
+ {
+ DataTable parent = DataProvider.CreateParentDataTable();
+ DataTable child = DataProvider.CreateChildDataTable();
+ DataSet ds = new DataSet();
+ ds.Tables.Add(parent);
+ ds.Tables.Add(child);
+
+ ds.Relations.Add("Relation1",parent.Columns[0],child.Columns[0],false);
+
+ //Create the computed columns
+
+ DataColumn dcComputedParent = new DataColumn("computedParent",Type.GetType("System.Double"));
+ parent.Columns.Add(dcComputedParent);
+ dcComputedParent.Expression = "sum(child(Relation1)." + child.Columns[1].ColumnName + ")";
+
+ double preCalculatedExpression;
+
+ foreach (DataRow dr in parent.Rows)
+ {
+ object o = child.Compute("sum(" + child.Columns[1].ColumnName + ")",
+ parent.Columns[0].ColumnName + "=" + dr[0]);
+ if (o == DBNull.Value)
+ {
+ Assert.AreEqual(dr["computedParent"],o,"dcear#1");
+ }
+ else
+ {
+ preCalculatedExpression = Convert.ToDouble(o);
+ Assert.AreEqual(dr["computedParent"],preCalculatedExpression,"dcear#2");
+ }
+ }
+
+ DataColumn dcComputedChild = new DataColumn("computedChild",Type.GetType("System.Double"));
+ child.Columns.Add(dcComputedChild);
+ dcComputedChild.Expression = "Parent." + parent.Columns[0].ColumnName;
+
+ int index=0;
+ double val;
+ foreach (DataRow dr in child.Rows)
+ {
+ val = Convert.ToDouble(dr.GetParentRow("Relation1")[0]);
+ Assert.AreEqual(dr["computedChild"],val,"dcear#3");
+ index++;
+ }
+ } + + public void Expression_IIF()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataColumn dcComputedParent = new DataColumn("computedCol",Type.GetType("System.Double"));
+ dcComputedParent.DefaultValue=25.5;
+ dt.Columns.Add(dcComputedParent);
+ dcComputedParent.Expression = "IIF(" + dt.Columns[0].ColumnName + ">3" + ",1,2)";
+
+ double val;
+ foreach (DataRow dr in dt.Rows)
+ {
+ val = (int)dr[0] >3 ? 1:2;
+ Assert.AreEqual(val,dr["computedCol"],"dceiif#1");
+ }
+ //Now reset the expression and check that the column got his deafult value
+
+ dcComputedParent.Expression = null;
+ foreach (DataRow dr in dt.Rows)
+ {
+ Assert.AreEqual(25.5,dr["computedCol"],"dceiif#2");
+ }
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataRelationCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/DataRelationCollectionTest2.cs index 9f7361e084b..652490054d3 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRelationCollectionTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRelationCollectionTest2.cs @@ -55,6 +55,12 @@ namespace MonoTests.System.Data return ds; } + [SetUp] + public void SetUp() + { + changesCounter = 0; + } + [Test] public void AddRange() { DataSet ds = getDataSet(); @@ -161,7 +167,6 @@ namespace MonoTests.System.Data [Test] public void Clear() { - changesCounter = 0; DataSet ds = getDataSet(); ds.Relations.Add(ds.Tables[0].Columns["ParentId"],ds.Tables[1].Columns["ParentId"]); @@ -176,7 +181,6 @@ namespace MonoTests.System.Data /// </summary> [Test] public void CollectionChanged() { - changesCounter = 0; DataSet ds = getDataSet(); ds.Relations.CollectionChanged+=new CollectionChangeEventHandler(Relations_CollectionChanged); @@ -299,5 +303,226 @@ namespace MonoTests.System.Data Assert.AreEqual("rel1", ds.Relations[0].RelationName, "DRC63"); Assert.AreEqual("rel2", ds.Relations[1].RelationName, "DRC64"); } + + [Test] + public void Add_DataColumn1()
+ {
+ DataSet ds = DataProvider.CreateForigenConstraint();
+ int originalRelationsCount = ds.Relations.Count;
+
+ DataRelation rel = new DataRelation("rel1",ds.Tables[0].Columns["ParentId"]
+ ,ds.Tables[1].Columns["ParentId"]);
+
+ ds.Relations.Add(rel);
+
+ Assert.AreEqual(originalRelationsCount+1,ds.Relations.Count,"DRC70");
+
+ Assert.AreEqual(1,ds.Tables[0].ChildRelations.Count,"DRC71"); //When adding a relation,it's also added on the tables
+ Assert.AreEqual(1,ds.Tables[1].ParentRelations.Count,"DRC72");
+
+ Assert.AreEqual(typeof(UniqueConstraint),ds.Tables[0].Constraints[0].GetType(),"DRC73");
+ Assert.AreEqual(typeof(ForeignKeyConstraint),ds.Tables[1].Constraints[0].GetType(),"DRC74");
+
+ try
+ {
+ ds.Relations.Add(rel);
+ Assert.Fail("DR75: Add failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DR76: Add. Wrong exception type. Got:" + exc);
+ }
+
+ ds.Relations.Add(null);
+ }
+
+ [Test] + public void Add_DataColumn2()
+ {
+ DataSet ds = GetDataSet();
+ DataTable dt1 = ds.Tables[0];
+ DataTable dt2 = ds.Tables[1];
+
+ dt1.ChildRelations.Add(new DataRelation("rel1",dt1.Columns["ParentId"],dt2.Columns["ParentId"]));
+
+ Assert.AreEqual(1,dt1.ChildRelations.Count,"DRC77");
+ Assert.AreEqual(1,dt2.ParentRelations.Count,"DRC78");
+ Assert.AreEqual(1,ds.Relations.Count,"DRC79"); //When adding relationship,it's also added on the dataset
+ }
+
+ [Test] + public void Add_DataColumn3()
+ {
+ DataSet ds = GetDataSet();
+
+ ds.Tables[1].ParentRelations.Add(new DataRelation("rel1",ds.Tables[0].Columns["ParentId"],ds.Tables[1].Columns["ParentId"]));
+
+ Assert.AreEqual(1,ds.Tables[0].ChildRelations.Count,"DRC80");
+ Assert.AreEqual(1,ds.Tables[1].ParentRelations.Count,"DRC81");
+ Assert.AreEqual(1,ds.Relations.Count,"DRC82");
+ }
+
+ [Test] + public void Add_DataColumn4()
+ {
+ DataSet ds = GetDataSet();
+ DataTable dt = new DataTable();
+ dt.Columns.Add("ParentId");
+ try
+ {
+ ds.Relations.Add(new DataRelation("rel1",dt.Columns[0],ds.Tables[0].Columns[0]));
+ Assert.Fail("DRC82: Add failed to throw InvalidConstraintException");
+ }
+ catch (InvalidConstraintException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRC83: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ [Test] + public void Add_DataColumn5()
+ {
+ DataSet ds = GetDataSet();
+ }
+
+ private DataSet GetDataSet()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt1 = DataProvider.CreateParentDataTable();
+ DataTable dt2 = DataProvider.CreateChildDataTable();
+
+ ds.Tables.Add(dt1);
+ ds.Tables.Add(dt2);
+ return ds;
+ } + + [Test] + public void Remove_DataColumn()
+ {
+ DataSet ds = getDataSet();
+ DataSet ds1 = getDataSet();
+ DataRelation rel1 = new DataRelation("rel1",ds.Tables[0].Columns["ParentId"],ds.Tables[1].Columns["ParentId"]);
+ DataRelation rel2 = new DataRelation("rel2",ds.Tables[0].Columns["String1"],ds.Tables[1].Columns["String1"]);
+
+ ds.Relations.Add(rel1);
+ ds.Relations.Add(rel2);
+
+ Assert.AreEqual(2,ds.Relations.Count,"DRC84");
+
+ ds.Relations.CollectionChanged+=new CollectionChangeEventHandler(Relations_CollectionChanged);
+ //Perform remove
+
+ ds.Relations.Remove(rel1);
+ Assert.AreEqual(1,ds.Relations.Count,"DRC85");
+ Assert.AreEqual("rel2",ds.Relations[0].RelationName,"DRC86");
+ ds.Relations.Remove(rel2);
+ Assert.AreEqual(0,ds.Relations.Count,"DRC87");
+ Assert.AreEqual(2,changesCounter,"DRC88"); //How many times the event fired
+ ds.Relations.Remove((DataRelation)null);
+
+ try
+ {
+ DataRelation rel3 = new DataRelation("rel3",ds1.Tables[0].Columns["ParentId"],ds1.Tables[1].Columns["ParentId"]);
+ ds.Relations.Remove(rel3);
+ Assert.Fail("DRC89: Remove failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRC90: Remove. Wrong exception type. Got:" + exc);
+ }
+ } + + [Test] + public void Remove_String()
+ {
+ DataSet ds = getDataSet();
+ DataSet ds1 = getDataSet();
+ DataRelation rel1 = new DataRelation("rel1",ds.Tables[0].Columns["ParentId"],ds.Tables[1].Columns["ParentId"]);
+ DataRelation rel2 = new DataRelation("rel2",ds.Tables[0].Columns["String1"],ds.Tables[1].Columns["String1"]);
+
+ ds.Relations.Add(rel1);
+ ds.Relations.Add(rel2);
+
+ Assert.AreEqual(ds.Relations.Count,2,"DRC91");
+
+ ds.Relations.CollectionChanged+=new CollectionChangeEventHandler(Relations_CollectionChanged);
+ //Perform remove
+
+ ds.Relations.Remove("rel1");
+ Assert.AreEqual(1,ds.Relations.Count,"DRC92");
+ Assert.AreEqual("rel2",ds.Relations[0].RelationName,"DRC93");
+ ds.Relations.Remove("rel2");
+ Assert.AreEqual(0,ds.Relations.Count,"DRC94");
+ Assert.AreEqual(2,changesCounter,"DRC95"); //How many times the event fired
+
+ try
+ {
+ ds.Relations.Remove((string)null);
+ Assert.Fail("DRC96: Remove failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRC97: Remove. Wrong exception type. Got:" + exc);
+ }
+
+
+ try
+ {
+ //DataRelation rel3 = new DataRelation("rel3",ds1.Tables[0].Columns["ParentId"],ds1.Tables[1].Columns["ParentId"]);
+ ds.Relations.Remove("rel3");
+ Assert.Fail("DRC98: Remove failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRC99: Remove. Wrong exception type. Got:" + exc);
+ }
+ } + + private void RemoveAt()
+ {
+ DataSet ds = getDataSet();
+ DataSet ds1 = getDataSet();
+ DataRelation rel1 = new DataRelation("rel1",ds.Tables[0].Columns["ParentId"],ds.Tables[1].Columns["ParentId"]);
+ DataRelation rel2 = new DataRelation("rel2",ds.Tables[0].Columns["String1"],ds.Tables[1].Columns["String1"]);
+
+ ds.Relations.Add(rel1);
+ ds.Relations.Add(rel2);
+
+ Assert.AreEqual(2,ds.Relations.Count,"DRC100");
+
+ ds.Relations.CollectionChanged+=new CollectionChangeEventHandler(Relations_CollectionChanged);
+ //Perform remove
+
+ ds.Relations.RemoveAt(0);
+ Assert.AreEqual(1,ds.Relations.Count,"DRC101");
+ Assert.AreEqual("rel2",ds.Relations[0].RelationName,"DRC102");
+ ds.Relations.RemoveAt(0);
+ Assert.AreEqual(0,ds.Relations.Count,"DRC103");
+ Assert.AreEqual(2,changesCounter,"DRC104"); //How many times the event fired
+
+
+ try
+ {
+ //DataRelation rel3 = new DataRelation("rel3",ds1.Tables[0].Columns["ParentId"],ds1.Tables[1].Columns["ParentId"]);
+ ds.Relations.RemoveAt(-1);
+ Assert.Fail("DRC105: RemoveAt failed to throw IndexOutOfRangeException");
+ }
+ catch (IndexOutOfRangeException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRC106: RemoveAt. Wrong exception type. Got:" + exc);
+ }
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataRowCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/DataRowCollectionTest2.cs index 039ad1e7ffa..67549b065a3 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRowCollectionTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRowCollectionTest2.cs @@ -96,5 +96,290 @@ namespace MonoTests.System.Data Assert.AreEqual(counter-1, dt.Rows.Count, "DRWC11"); Assert.AreEqual(null, dt.Rows.Find(1), "DRWC12"); } + + [Test] + public void DataRowCollection_Add_D1() + { + DataTable dt = DataProvider.CreateParentDataTable(); + dt.Rows.Clear(); + DataRow dr = dt.NewRow(); + dr["ParentId"] = 10; + dr["String1"] = "string1"; + dr["String2"] = string.Empty; + dr["ParentDateTime"] = new DateTime(2004,12,15); + dr["ParentDouble"] = 3.14; + dr["ParentBool"] = false; + + dt.Rows.Add(dr); + + Assert.AreEqual(1,dt.Rows.Count,"RDWC13"); + Assert.AreEqual(dr,dt.Rows[0],"DRWC14"); + } + + [Test] + [ExpectedException(typeof(ArgumentException))] + public void DataRowCollection_Add_D2() + { + DataTable dt = DataProvider.CreateParentDataTable(); + dt.Rows.Add(dt.Rows[0]); + } + + [Test] + [ExpectedException(typeof(ArgumentNullException))] + public void DataRowCollection_Add_D3() + { + DataTable dt = DataProvider.CreateParentDataTable(); + dt.Rows.Add((DataRow)null); + } + + [Test] + [ExpectedException(typeof(ArgumentException))] + public void DataRowCollection_Add_D4() + { + DataTable dt = DataProvider.CreateParentDataTable(); + DataTable dt1 = DataProvider.CreateParentDataTable(); + + dt.Rows.Add(dt1.Rows[0]); + } + + [Test] + public void DataRowCollection_Add_O1() + { + DataTable dt = DataProvider.CreateParentDataTable(); + dt.Rows.Clear(); + dt.Rows.Add(new object[] {1,"1-String1","1-String2",new DateTime(2005,1,1,0,0,0,0),1.534,true}); + Assert.AreEqual(1,dt.Rows.Count,"DRWC15"); + Assert.AreEqual(1,dt.Rows[0]["ParentId"],"DRWC16"); + Assert.AreEqual("1-String1",dt.Rows[0]["String1"],"DRWC17"); + Assert.AreEqual("1-String2",dt.Rows[0]["String2"],"DRWC18"); + Assert.AreEqual(new DateTime(2005,1,1,0,0,0,0),dt.Rows[0]["ParentDateTime"],"DRWC19"); + Assert.AreEqual(1.534,dt.Rows[0]["ParentDouble"],"DRWC20"); + Assert.AreEqual(true,dt.Rows[0]["ParentBool"],"DRWC21"); + + } + + [Test] + public void DataRowCollection_Add_O2() + { + DataTable dt = DataProvider.CreateParentDataTable(); + int count = dt.Rows.Count; + dt.Rows.Add(new object[] {8,"1-String1","1-String2",new DateTime(2005,1,1,0,0,0,0),1.534}); + Assert.AreEqual(count+1,dt.Rows.Count,"DRWC14"); + } + +// [Test] +// [ExpectedException(typeof(ArgumentException))] +// public void DataRowCollection_Add_O3() +// { +// DataTable dt = DataProvider.CreateParentDataTable(); +// dt.Rows.Add(new object[] {8,"1-String1","1-String2",new DateTime(2005,1,1,0,0,0,0),1.534}); +// } + + [Test] + [ExpectedException(typeof(NullReferenceException))] +#if !TARGET_JVM
+ [NUnit.Framework.Category ("NotWorking")]
+#endif + public void DataRowCollection_Add_O4() + { + DataTable dt = DataProvider.CreateParentDataTable(); + dt.Rows.Add((Object[])null); + } + + [Test]
+ public void DataRowCollection_Clear1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ int count = dt.Rows.Count;
+ Assert.AreEqual(count !=0,true);
+ dt.Rows.Clear();
+ Assert.AreEqual(0,dt.Rows.Count,"DRWC15");
+ }
+
+ [Test]
+ [ExpectedException(typeof(InvalidConstraintException))]
+ public void DataRowCollection_Clear2()
+ {
+ DataSet ds = DataProvider.CreateForigenConstraint();
+
+ ds.Tables[0].Rows.Clear(); //Try to clear the parent table
+ } + + [Test]
+ public void DataRowCollection_Contains_O1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0]};
+
+ Assert.AreEqual(true,dt.Rows.Contains(1),"DRWC16");
+ Assert.AreEqual(false,dt.Rows.Contains(10),"DRWC17");
+ }
+
+ [Test]
+ [ExpectedException(typeof(MissingPrimaryKeyException))]
+ public void DataRowCollection_Contains_O2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ Assert.AreEqual(false,dt.Rows.Contains(1),"DRWC18");
+ }
+
+ [Test]
+ public void DataRowCollection_Contains_O3()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0],dt.Columns[1]};
+
+ //Prepare values array
+ object[] arr = new object[2];
+ arr[0] = 1;
+ arr[1] = "1-String1";
+
+ Assert.AreEqual(true,dt.Rows.Contains( (object[])arr),"DRWC19");
+
+ arr[0] = 8;
+
+ Assert.AreEqual(false,dt.Rows.Contains( (object[])arr),"DRWC20");
+
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void DataRowCollection_Contains_O4()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0],dt.Columns[1]};
+
+ //Prepare values array
+ object[] arr = new object[1];
+ arr[0] = 1;
+
+ Assert.AreEqual(false,dt.Rows.Contains((object[]) arr),"DRWC21");
+ } + + [Test]
+ public void DataRowCollection_Find_O1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0]};
+
+ Assert.AreEqual(dt.Rows[0],dt.Rows.Find(1),"DRWC22");
+ Assert.AreEqual(null,dt.Rows.Find(10),"DRWC23");
+ }
+
+ [Test]
+ [ExpectedException(typeof(MissingPrimaryKeyException))]
+ public void DataRowCollection_Find_O2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+
+ Assert.AreEqual(null,dt.Rows.Find(1),"DRWC24");
+ }
+
+ [Test]
+ public void DataRowCollection_Find_O3()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0],dt.Columns[1]};
+
+ //Prepare values array
+ object[] arr = new object[2];
+ arr[0] = 2;
+ arr[1] = "2-String1";
+
+ Assert.AreEqual(dt.Rows[1],dt.Rows.Find( (object[])arr),"DRWC25");
+
+ arr[0] = 8;
+
+ Assert.AreEqual(null,dt.Rows.Find( (object[])arr),"DRWC26");
+
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void DataRowCollection_Find_O4()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.PrimaryKey= new DataColumn[] {dt.Columns[0],dt.Columns[1]};
+
+ //Prepare values array
+ object[] arr = new object[1];
+ arr[0] = 1;
+
+ Assert.AreEqual(null,dt.Rows.Find((object[]) arr),"DRWC27");
+ } + + [Test]
+ public void DataRowCollection_InsertAt_DI1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataRow dr = GetNewDataRow(dt);
+ dt.Rows.InsertAt(dr,0);
+
+ Assert.AreEqual(dr,dt.Rows[0],"DRWC28"); //Begin
+ }
+
+ [Test]
+ public void DataRowCollection_InsertAt_DI2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataRow dr = GetNewDataRow(dt);
+ dt.Rows.InsertAt(dr,3);
+
+ Assert.AreEqual(dr,dt.Rows[3],"DRWC29"); //Middle
+ }
+
+ [Test]
+ public void DataRowCollection_InsertAt_DI3()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataRow dr = GetNewDataRow(dt);
+ dt.Rows.InsertAt(dr,300);
+
+ Assert.AreEqual(dr,dt.Rows[dt.Rows.Count-1],"DRWC30"); //End
+ }
+
+ [Test]
+ [ExpectedException(typeof(IndexOutOfRangeException))]
+ public void DataRowCollection_InsertAt_DI4()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataRow dr = GetNewDataRow(dt);
+
+ dt.Rows.InsertAt(dr,-1);
+ }
+
+ private DataRow GetNewDataRow(DataTable dt)
+ {
+ DataRow dr = dt.NewRow();
+ dr["ParentId"] = 10;
+ dr["String1"] = "string1";
+ dr["String2"] = string.Empty;
+ dr["ParentDateTime"] = new DateTime(2004,12,15);
+ dr["ParentDouble"] = 3.14;
+ dr["ParentBool"] = false;
+ return dr;
+ } + + [Test]
+ public void DataRowCollection_Item1()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ int index=0;
+
+ foreach (DataRow dr in dt.Rows)
+ {
+ Assert.AreEqual(dr,dt.Rows[index],"DRWC31");
+ index++;
+ }
+ }
+
+ [Test]
+ [ExpectedException(typeof(IndexOutOfRangeException))]
+ public void DataRowCollection_Item2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+
+ DataRow dr = dt.Rows[-1];
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs b/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs index 0530eadc8ee..3d5db582c25 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRowTest2.cs @@ -1318,5 +1318,248 @@ namespace MonoTests.System.Data ds.Tables[0].Rows[0][0] = 10;
ds.Tables[0].EndLoadData(); //Foreign constraint violation } + + [Test] + public void BeginEdit()
+ {
+ DataTable myTable = new DataTable("myTable");
+ DataColumn dc = new DataColumn("Id",typeof(int));
+ dc.Unique=true;
+ myTable.Columns.Add(dc);
+ myTable.Rows.Add(new object[] {1});
+ myTable.Rows.Add(new object[] {2});
+ myTable.Rows.Add(new object[] {3});
+
+ DataRow myRow = myTable.Rows[0];
+
+ try
+ {
+ myRow[0] = 2; //row[0] now conflict with row[1]
+ Assert.Fail("DRW121: failed to throw ConstraintException");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW122: Add. Wrong exception type. Got:" + exc);
+ }
+
+ //Will NOT! throw exception
+ myRow.BeginEdit();
+ myRow[0] = 2; //row[0] now conflict with row[1]
+
+ DataTable dt = DataProvider.CreateParentDataTable();
+ DataRow dr = dt.Rows[0];
+ dr.Delete();
+ try
+ {
+ dr.BeginEdit();
+ Assert.Fail("DRW123: failed to throw DeletedRowInaccessibleException");
+ }
+ catch (DeletedRowInaccessibleException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW124: Add. Wrong exception type. Got:" + exc);
+ }
+ } + + [Test] + public void GetChildRows_DataRelation()
+ {
+ DataRow dr;
+ DataRow[] drArrExcepted,drArrResult;
+ DataTable dtChild,dtParent;
+ DataSet ds = new DataSet();
+
+ //Create tables
+ dtChild = DataProvider.CreateChildDataTable();
+ dtParent= DataProvider.CreateParentDataTable();
+
+ //Add tables to dataset
+ ds.Tables.Add(dtChild);
+ ds.Tables.Add(dtParent);
+ dr = dtParent.Rows[0];
+
+ //Add Relation
+ DataRelation dRel = new DataRelation("Parent-Child",dtParent.Columns["ParentId"],dtChild.Columns["ParentId"]);
+ ds.Relations.Add(dRel);
+ //Get Excepted result
+ drArrExcepted = dtChild.Select("ParentId=" + dr["ParentId"]);
+ //Get Result
+ drArrResult = dr.GetChildRows(dRel);
+
+ Assert.AreEqual(drArrExcepted, drArrResult, "DRW125");
+ } + + [Test] + public void GetParentRows_DataRelation_DataRowVersion()
+ {
+ DataRow drParent,drChild;
+ DataRow[] drArrExcepted,drArrResult;
+ DataTable dtChild,dtParent;
+ DataSet ds = new DataSet();
+ //Create tables
+ dtChild = DataProvider.CreateChildDataTable();
+ dtParent= DataProvider.CreateParentDataTable();
+ //Add tables to dataset
+ ds.Tables.Add(dtChild);
+ ds.Tables.Add(dtParent);
+
+ drParent = dtParent.Rows[0];
+ drChild = dtChild.Select("ParentId=" + drParent["ParentId"])[0];
+
+ //Duplicate several rows in order to create Many to Many relation
+ dtParent.ImportRow(drParent);
+ dtParent.ImportRow(drParent);
+ dtParent.ImportRow(drParent);
+
+ //Add Relation
+ DataRelation dRel = new DataRelation("Parent-Child",dtParent.Columns["ParentId"],dtChild.Columns["ParentId"],false);
+ ds.Relations.Add(dRel);
+
+ //Get Excepted result
+ drArrExcepted = dtParent.Select("ParentId=" + drParent["ParentId"],"",DataViewRowState.CurrentRows );
+ //Get Result DataRowVersion.Current
+ drArrResult = drChild.GetParentRows(dRel,DataRowVersion.Current);
+ Assert.AreEqual(drArrExcepted, drArrResult, "DRW126");
+
+ //Get Excepted result
+ drArrExcepted = dtParent.Select("ParentId=" + drParent["ParentId"],"",DataViewRowState.OriginalRows );
+ //Get Result DataRowVersion.Current
+ drArrResult = drChild.GetParentRows(dRel,DataRowVersion.Original );
+ Assert.AreEqual(drArrExcepted, drArrResult, "DRW127");
+
+ //Get Excepted result, in this case Current = Default
+ drArrExcepted = dtParent.Select("ParentId=" + drParent["ParentId"],"",DataViewRowState.CurrentRows);
+ //Get Result DataRowVersion.Current
+ drArrResult = drChild.GetParentRows(dRel,DataRowVersion.Default );
+ Assert.AreEqual(drArrExcepted, drArrResult, "DRW128");
+
+ try
+ {
+ DataTable dtOtherParent = DataProvider.CreateParentDataTable();
+ DataTable dtOtherChild = DataProvider.CreateChildDataTable();
+
+ DataRelation drl = new DataRelation("newRelation",dtOtherParent.Columns[0],dtOtherChild.Columns[0]);
+ drChild.GetParentRows(drl,DataRowVersion.Current);
+ Assert.Fail("DRW129: failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW130: Add. Wrong exception type. Got:" + exc);
+ } + } + + [Test] + public void ItemArray()
+ {
+ DataTable dt = GetDataTable();
+ DataRow dr = dt.Rows[0];
+
+ Assert.AreEqual(1, (int)dr.ItemArray[0] , "DRW131" );
+
+ Assert.AreEqual("Ofer", (string)dr.ItemArray[1] , "DRW132" );
+
+ dt = GetDataTable();
+
+ dr = dt.Rows[0];
+
+ //Changing row via itemArray
+
+ dt.Rows[0].ItemArray = new object[] {2,"Oren"};
+
+ Assert.AreEqual(2, (Int32)dr.ItemArray[0] , "DRW133" );
+ Assert.AreEqual("Oren", (string)dr.ItemArray[1] , "DRW134" );
+
+ try
+ {
+ dt.Rows[0].ItemArray = new object[] {2,"Oren","some1else"};
+ Assert.Fail("DRW135: failed to throw ArgumentException");
+ }
+ catch (ArgumentException) {}
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW136: Add. Wrong exception type. Got:" + exc);
+ }
+ }
+
+ private DataTable GetDataTable()
+ {
+ DataTable dt = new DataTable("myTable");
+ dt.Columns.Add("Id",typeof(int));
+ dt.Columns.Add("Name",typeof(string));
+
+ DataRow dr = dt.NewRow();
+ dr.ItemArray = new object[] {1,"Ofer"};
+
+ dt.Rows.Add(dr);
+
+ return dt;
+ } + + public void RowError()
+ {
+ DataTable dt = new DataTable("myTable");
+ DataRow dr = dt.NewRow();
+
+ Assert.AreEqual(string.Empty , dr.RowError, "DRW137");
+
+ dr.RowError = "Err";
+
+ Assert.AreEqual("Err", dr.RowError , "DRW138" );
+
+ DataTable dt1 = DataProvider.CreateUniqueConstraint();
+
+ try
+ {
+ dt1.BeginLoadData();
+
+ dr = dt1.NewRow();
+ dr[0] = 3;
+ dt1.Rows.Add(dr);
+ dt1.EndLoadData();
+ Assert.Fail("DRW139: failed to throw ConstraintException");
+ }
+ catch (ConstraintException)
+ {
+ Assert.AreEqual(2,dt1.GetErrors().Length,"DRW141");
+ Assert.AreEqual(true,dt1.GetErrors()[0].RowError.Length > 10,"DRW142");
+ Assert.AreEqual(true,dt1.GetErrors()[1].RowError.Length > 10,"DRW143");
+ }
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW144: Wrong exception type. Got:" + exc);
+ }
+
+
+ DataSet ds=null;
+ try
+ {
+ ds= DataProvider.CreateForigenConstraint();
+ ds.Tables[0].BeginLoadData();
+ ds.Tables[0].Rows[0][0] = 10; //Forigen constraint violation
+ //ds.Tables[0].AcceptChanges();
+ ds.Tables[0].EndLoadData();
+ Assert.Fail("DRW139: failed to throw ConstraintException");
+ }
+ catch (ConstraintException)
+ {
+ Assert.AreEqual(3,ds.Tables[1].GetErrors().Length,"DRW145");
+ for(int index=0;index<3;index++)
+ {
+ Assert.AreEqual(true,ds.Tables[1].GetErrors()[index].RowError.Length > 10,"RDW146");
+ }
+ }
+ catch (AssertionException exc) {throw exc;}
+ catch (Exception exc)
+ {
+ Assert.Fail("DRW147: Wrong exception type. Got:" + exc);
+ }
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs b/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs index d11e093cb86..89136d6545e 100644 --- a/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataSetTest2.cs @@ -32,6 +32,7 @@ using System.Text; using System.IO; using System.Data; using MonoTests.System.Data.Utils; +using System.Xml; namespace MonoTests_System.Data { @@ -2384,34 +2385,34 @@ namespace MonoTests_System.Data { DataSet ds = new DataSet(); string xmlData = string.Empty; - xmlData += "<?xml version=\"1.0\"?>";
- xmlData += "<xs:schema id=\"SiteConfiguration\" targetNamespace=\"http://tempuri.org/PortalCfg.xsd\" xmlns:mstns=\"http://tempuri.org/PortalCfg.xsd\" xmlns=\"http://tempuri.org/PortalCfg.xsd\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" attributeFormDefault=\"qualified\" elementFormDefault=\"qualified\">";
- xmlData += "<xs:element name=\"SiteConfiguration\" msdata:IsDataSet=\"true\" msdata:EnforceConstraints=\"False\">";
- xmlData += "<xs:complexType>";
- xmlData += "<xs:choice maxOccurs=\"unbounded\">";
- xmlData += "<xs:element name=\"Tab\">";
- xmlData += "<xs:complexType>";
- xmlData += "<xs:sequence>";
- xmlData += "<xs:element name=\"Module\" minOccurs=\"0\" maxOccurs=\"unbounded\">";
- xmlData += "<xs:complexType>";
- xmlData += "<xs:attribute name=\"ModuleId\" form=\"unqualified\" type=\"xs:int\" />";
- xmlData += "</xs:complexType>";
- xmlData += "</xs:element>";
- xmlData += "</xs:sequence>";
- xmlData += "<xs:attribute name=\"TabId\" form=\"unqualified\" type=\"xs:int\" />";
- xmlData += "</xs:complexType>";
- xmlData += "</xs:element>";
- xmlData += "</xs:choice>";
- xmlData += "</xs:complexType>";
- xmlData += "<xs:key name=\"TabKey\" msdata:PrimaryKey=\"true\">";
- xmlData += "<xs:selector xpath=\".//mstns:Tab\" />";
- xmlData += "<xs:field xpath=\"@TabId\" />";
- xmlData += "</xs:key>";
- xmlData += "<xs:key name=\"ModuleKey\" msdata:PrimaryKey=\"true\">";
- xmlData += "<xs:selector xpath=\".//mstns:Module\" />";
- xmlData += "<xs:field xpath=\"@ModuleID\" />";
- xmlData += "</xs:key>";
- xmlData += "</xs:element>";
+ xmlData += "<?xml version=\"1.0\"?>"; + xmlData += "<xs:schema id=\"SiteConfiguration\" targetNamespace=\"http://tempuri.org/PortalCfg.xsd\" xmlns:mstns=\"http://tempuri.org/PortalCfg.xsd\" xmlns=\"http://tempuri.org/PortalCfg.xsd\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" attributeFormDefault=\"qualified\" elementFormDefault=\"qualified\">"; + xmlData += "<xs:element name=\"SiteConfiguration\" msdata:IsDataSet=\"true\" msdata:EnforceConstraints=\"False\">"; + xmlData += "<xs:complexType>"; + xmlData += "<xs:choice maxOccurs=\"unbounded\">"; + xmlData += "<xs:element name=\"Tab\">"; + xmlData += "<xs:complexType>"; + xmlData += "<xs:sequence>"; + xmlData += "<xs:element name=\"Module\" minOccurs=\"0\" maxOccurs=\"unbounded\">"; + xmlData += "<xs:complexType>"; + xmlData += "<xs:attribute name=\"ModuleId\" form=\"unqualified\" type=\"xs:int\" />"; + xmlData += "</xs:complexType>"; + xmlData += "</xs:element>"; + xmlData += "</xs:sequence>"; + xmlData += "<xs:attribute name=\"TabId\" form=\"unqualified\" type=\"xs:int\" />"; + xmlData += "</xs:complexType>"; + xmlData += "</xs:element>"; + xmlData += "</xs:choice>"; + xmlData += "</xs:complexType>"; + xmlData += "<xs:key name=\"TabKey\" msdata:PrimaryKey=\"true\">"; + xmlData += "<xs:selector xpath=\".//mstns:Tab\" />"; + xmlData += "<xs:field xpath=\"@TabId\" />"; + xmlData += "</xs:key>"; + xmlData += "<xs:key name=\"ModuleKey\" msdata:PrimaryKey=\"true\">"; + xmlData += "<xs:selector xpath=\".//mstns:Module\" />"; + xmlData += "<xs:field xpath=\"@ModuleID\" />"; + xmlData += "</xs:key>"; + xmlData += "</xs:element>"; xmlData += "</xs:schema>"; ds.ReadXmlSchema(new StringReader(xmlData)); @@ -2752,5 +2753,157 @@ namespace MonoTests_System.Data } #endif + ///<?xml version="1.0" encoding="utf-16"?> + ///<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + /// <xs:element name="NewDataSet" msdata:IsDataSet="true"> + /// <xs:complexType> + /// <xs:choice maxOccurs="unbounded"> + /// <xs:element name="Parent"> + /// <xs:complexType> + /// <xs:sequence> + /// <xs:element name="ParentId" type="xs:int" minOccurs="0"/> + /// <xs:element name="String1" type="xs:string" minOccurs="0"/> + /// <xs:element name="String2" type="xs:string" minOccurs="0"/> + /// <xs:element name="ParentDateTime" type="xs:dateTime" minOccurs="0"/> + /// <xs:element name="ParentDouble" type="xs:double" minOccurs="0"/> + /// <xs:element name="ParentBool" type="xs:boolean" minOccurs="0"/> + /// </xs:sequence> + /// </xs:complexType> + /// </xs:element> + /// </xs:choice> + /// </xs:complexType> + /// </xs:element> + ///</xs:schema> + + [Test] + public void ParentDataTableSchema() + { + XmlDocument testedSchema; + XmlNamespaceManager testedSchemaNamepaces; + InitParentDataTableSchema(out testedSchema, out testedSchemaNamepaces); + + TestNode("DataSet name", "/xs:schema/xs:element[@name='NewDataSet']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("Parent datatable name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element[@name='Parent']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("ParentId column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='ParentId']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("String1 column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='String1']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("String2 column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='String1']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("ParentDateTime column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='ParentDateTime']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("ParentDouble column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='ParentDouble']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("ParentBool column - name", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@name='ParentBool']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("Int columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@type='xs:int']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("string columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@type='xs:string']", 2, testedSchema, testedSchemaNamepaces); + + TestNode("dateTime columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@type='xs:dateTime']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("double columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@type='xs:double']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("boolean columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@type='xs:boolean']", 1, testedSchema, testedSchemaNamepaces); + + TestNode("minOccurs columns", "/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[@minOccurs='0']", 6, testedSchema, testedSchemaNamepaces); + } + + private void InitParentDataTableSchema(out XmlDocument schemaDocInit, out XmlNamespaceManager namespaceManagerToInit) + { + DataSet ds = new DataSet(); + ds.Tables.Add(DataProvider.CreateParentDataTable()); + string strXML = ds.GetXmlSchema(); + schemaDocInit = new XmlDocument(); + schemaDocInit.LoadXml(strXML); + namespaceManagerToInit = new XmlNamespaceManager(schemaDocInit.NameTable); + namespaceManagerToInit.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); + namespaceManagerToInit.AddNamespace("msdata", "urn:schemas-microsoft-com:xml-msdata"); + } + + private void TestNode(string description, string xPath, int expectedNodesCout, XmlDocument schemaDoc, XmlNamespaceManager nm) + { + int actualNodeCount = schemaDoc.SelectNodes(xPath, nm).Count; + Assert.AreEqual(expectedNodesCout,actualNodeCount, "DS75" + description); + } + + [Test] + public void WriteXml_Stream() + { + { + DataSet ds = new DataSet(); + string input = "<a><b><c>2</c></b></a>"; + System.IO.StringReader sr = new System.IO.StringReader(input) ; + System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ; + ds.ReadXml (xReader); + + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + System.IO.StringWriter sw = new System.IO.StringWriter(sb); + System.Xml.XmlTextWriter xWriter = new System.Xml.XmlTextWriter(sw); + ds.WriteXml(xWriter); + string output = sb.ToString(); + Assert.AreEqual(input,output, "DS76"); + } + { + DataSet ds = new DataSet(); + string input = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>2</c></b></a>"; + string expectedOutput = "<a><b><c>2</c></b></a>"; + System.IO.StringReader sr = new System.IO.StringReader(input) ; + System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ; + ds.ReadXml (xReader); + + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + System.IO.StringWriter sw = new System.IO.StringWriter(sb); + System.Xml.XmlTextWriter xWriter = new System.Xml.XmlTextWriter(sw); + ds.WriteXml(xWriter); + string output = sb.ToString(); + Assert.AreEqual(expectedOutput,output, "DS77"); + } + { + DataSet ds = new DataSet("DSName"); + System.IO.StringWriter sr = new System.IO.StringWriter(); + ds.WriteXml(sr); + Assert.AreEqual("<DSName />",sr.ToString(), "DS78"); + } + { + DataSet ds = new DataSet(); + DataTable dt; + + //Create parent table. + dt = ds.Tables.Add("ParentTable"); + dt.Columns.Add("ParentTable_Id", typeof(int)); + dt.Columns.Add("ParentTableCol", typeof(int)); + dt.Rows.Add(new object[] {0,1}); + + //Create child table. + dt = ds.Tables.Add("ChildTable"); + dt.Columns.Add("ParentTable_Id", typeof(int)); + dt.Columns.Add("ChildTableCol", typeof(string)); + dt.Rows.Add(new object[] {0,"aa"}); + + //Add a relation between parent and child table. + ds.Relations.Add("ParentTable_ChildTable", ds.Tables["ParentTable"].Columns["ParentTable_Id"], ds.Tables["ChildTable"].Columns["ParentTable_Id"], true); + ds.Relations["ParentTable_ChildTable"].Nested=true; + + //Reomve the Parent_Child relation. + dt = ds.Tables["ChildTable"]; + dt.ParentRelations.Remove("ParentTable_ChildTable"); + + //Remove the constraint created automatically to enforce the "ParentTable_ChildTable" relation. + dt.Constraints.Remove("ParentTable_ChildTable"); + + //Remove the child table from the dataset. + ds.Tables.Remove("ChildTable"); + + //Get the xml representation of the dataset. + System.IO.StringWriter sr = new System.IO.StringWriter(); + ds.WriteXml(sr); + string xml = sr.ToString(); + + Assert.AreEqual(-1,xml.IndexOf("<ChildTable>"), "DS79"); + } + } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataSetTypedDataSetTest.cs b/mcs/class/System.Data/Test/System.Data/DataSetTypedDataSetTest.cs new file mode 100644 index 00000000000..93950867ae5 --- /dev/null +++ b/mcs/class/System.Data/Test/System.Data/DataSetTypedDataSetTest.cs @@ -0,0 +1,1564 @@ +// 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 System; +using System.ComponentModel; +using System.Data; +using MonoTests.System.Data.Utils; +using System.Collections; +using System.Runtime.Serialization; +using System.Xml; +using System.Xml.Schema; +using System.IO; +using System.Globalization; + +namespace MonoTests.System.Data +{ + [TestFixture] + public class DataSetTypedDataSetTest + { + private string EventStatus = string.Empty ; + + [Test] + public void TypedDataSet() + { + int i = 0; + //check dataset constructor + myTypedDataSet ds = null; + DataSet unTypedDs = new DataSet(); + ds = new myTypedDataSet(); + Assert.IsFalse(ds == null ,"TDS0" ); + Assert.AreEqual(typeof(myTypedDataSet), ds.GetType() ,"TDS1" ); + + // fill dtataset + ds.ReadXml("Test\\System.Data\\typeddataset.xml"); + + // check DataSet named property "Orders" + myTypedDataSet.OrdersDataTable tblOrders = null; + tblOrders = ds.Orders; + Assert.AreEqual(ds.Tables["Orders"],tblOrders ,"TDS2"); + + //check DataSet named property Orders - by index"); + tblOrders = ds.Orders; + Assert.AreEqual(ds.Tables[1],tblOrders ,"TDS3"); + + //add new row AddTableNameRow, check row count"); + i = tblOrders.Rows.Count; + tblOrders.AddOrdersRow("SAVEA",1,new DateTime(1998,05,01,00,00,00,000) + ,new DateTime(1998,05,29,00,00,00,000) + ,new DateTime(1998,05,04,00,00,00,000),1,30.0900m + ,"Save-a-lot Markets","187 Suffolk Ln.","Boise","ID","83720","USA"); + Assert.AreEqual(i+1 ,tblOrders.Rows.Count,"TDS5"); + + //check the new row AutoIncrement field - AddTableNameRow + i = (int)tblOrders.Rows[tblOrders.Rows.Count-2][0]; + Assert.AreEqual(i+1 ,(int)tblOrders.Rows[tblOrders.Rows.Count-1][0],"TDS6"); + + //Create New Row using NewTableNameRow, check row != null + myTypedDataSet.OrdersRow drOrders = null; + drOrders = tblOrders.NewOrdersRow(); + Assert.IsFalse(drOrders == null ,"TDS7"); + + //Create New Row using NewTableNameRow, check row state + Assert.AreEqual(DataRowState.Detached, drOrders.RowState , "TDS8"); + + //add new row NewTableNameRow, check row count + //drOrders.OrderID = DBNull.Value; + drOrders.CustomerID = "GREAL"; + drOrders.EmployeeID = 4; + drOrders.OrderDate = new DateTime(1998,04,30,00,00,00,000); + drOrders.RequiredDate = new DateTime(1998,06,11,00,00,00,000); + drOrders["ShippedDate"] = DBNull.Value; + drOrders.ShipVia = 3; + drOrders.Freight = 14.0100m; + drOrders.ShipName = "Great Lakes"; + drOrders.ShipAddress = "Food Market"; + drOrders.ShipCity = "Baker Blvd."; + drOrders.ShipRegion = "Eugene"; + drOrders.ShipPostalCode = "OR 97403"; + drOrders.ShipCountry = "USA"; + + i = tblOrders.Rows.Count; + tblOrders.AddOrdersRow(drOrders); + Assert.AreEqual(i+1 ,tblOrders.Rows.Count,"TDS9"); + + //check StrongTypingException + try + { + DateTime d = drOrders.ShippedDate; //drOrders.ShippedDate = null, will raise exception + Assert.Fail("TDS10: Failed to throw StrongTypingException"); + } + catch (StrongTypingException) {} + catch (AssertionException exc) {throw exc;} + catch (Exception exc) + { + Assert.Fail("TDS11: Wrong exception type. Got:" + exc); + } + + //check the new row AutoIncrement field - NewTableNameRow + i = (int)tblOrders.Rows[tblOrders.Rows.Count-2][0]; + Assert.AreEqual(i+1 ,(int)tblOrders.Rows[tblOrders.Rows.Count-1][0],"TDS12"); + + // convenience IsNull functions + // only if it can be null + Assert.IsFalse(drOrders.IsShipAddressNull() ,"TDS13"); + + drOrders.SetShipAddressNull(); + Assert.IsTrue(drOrders.IsShipAddressNull() ,"TDS14"); + + // Table exposes a public property Count == table.Rows.Count + Assert.AreEqual(tblOrders.Count ,tblOrders.Rows.Count , "TDS15"); + + + // find function + myTypedDataSet.OrdersRow dr = tblOrders[0]; + Assert.AreEqual(tblOrders.FindByOrderID(dr.OrderID),dr,"TDS16" ); + + //Remove row and check row count + i = tblOrders.Count; + myTypedDataSet.OrdersRow drr = tblOrders[0]; + tblOrders.RemoveOrdersRow(drr); + Assert.AreEqual(i-1 ,tblOrders.Count,"TDS17"); + + //first column is readonly + Assert.IsTrue(tblOrders.OrderIDColumn.ReadOnly ,"TDS18"); + + //read only exception + try + { + tblOrders[0].OrderID = 99; + Assert.Fail("TDS19: Failed to throw ReadOnlyException"); + } + catch (ReadOnlyException) {} + catch (AssertionException exc) {throw exc;} + catch (Exception exc) + { + Assert.Fail("TDS20: Wrong exception type. Got:" + exc); + } + + tblOrders.AcceptChanges(); + + //Check table events + // add event handlers + ds.Orders.OrdersRowChanging += new myTypedDataSet.OrdersRowChangeEventHandler(T_Changing); + ds.Orders.OrdersRowChanged += new myTypedDataSet.OrdersRowChangeEventHandler(T_Changed); + ds.Orders.OrdersRowDeleting += new myTypedDataSet.OrdersRowChangeEventHandler(T_Deleting); + ds.Orders.OrdersRowDeleted += new myTypedDataSet.OrdersRowChangeEventHandler(T_Deleted); + + //RowChange event order + tblOrders[0].ShipCity = "Tel Aviv"; + Assert.AreEqual("AB",EventStatus , "TDS21"); + + EventStatus = string.Empty; + //RowDelet event order + tblOrders[0].Delete(); + Assert.AreEqual("AB",EventStatus , "TDS22"); + + //expose DataColumn as property + Assert.AreEqual(ds.Orders.OrderIDColumn ,ds.Tables["Orders"].Columns["OrderID"],"TDS23"); + + //Accept changes for all deleted and changedd rows. + ds.AcceptChanges(); + + //check relations + //ChildTableRow has property ParentTableRow + myTypedDataSet.OrdersRow dr1 = ds.Order_Details[0].OrdersRow; + DataRow dr2 = ds.Order_Details[0].GetParentRow(ds.Relations[0]); + Assert.AreEqual(dr1 ,dr2 ,"TDS24"); + + //ParentTableRow has property ChildTableRow + myTypedDataSet.Order_DetailsRow[] drArr1 = ds.Orders[0].GetOrder_DetailsRows(); + DataRow[] drArr2 = ds.Orders[0].GetChildRows(ds.Relations[0]); + Assert.AreEqual(drArr1 ,drArr2,"TDS25"); + } + + protected void T_Changing(object sender, myTypedDataSet.OrdersRowChangeEvent e) + { + EventStatus += "A"; + } + + protected void T_Changed(object sender, myTypedDataSet.OrdersRowChangeEvent e) + { + EventStatus += "B"; + } + + protected void T_Deleting(object sender, myTypedDataSet.OrdersRowChangeEvent e) + { + EventStatus += "A"; + } + + protected void T_Deleted(object sender, myTypedDataSet.OrdersRowChangeEvent e) + { + EventStatus += "B"; + } + + [Serializable()] + [DesignerCategoryAttribute("code")] + [ToolboxItem(true)] + public class myTypedDataSet : DataSet + { + private Order_DetailsDataTable tableOrder_Details; + + private OrdersDataTable tableOrders; + + private DataRelation relationOrdersOrder_x0020_Details; + + public myTypedDataSet() + { + this.InitClass(); + CollectionChangeEventHandler schemaChangedHandler = new CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + protected myTypedDataSet(SerializationInfo info, StreamingContext context) + { + string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); + if ((strSchema != null)) + { + DataSet ds = new DataSet(); + ds.ReadXmlSchema(new XmlTextReader(new StringReader(strSchema))); + if ((ds.Tables["Order Details"] != null)) + { + this.Tables.Add(new Order_DetailsDataTable(ds.Tables["Order Details"])); + } + if ((ds.Tables["Orders"] != null)) + { + this.Tables.Add(new OrdersDataTable(ds.Tables["Orders"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, MissingSchemaAction.Add); + this.InitVars(); + } + else + { + this.InitClass(); + } + this.GetSerializationData(info, context); + CollectionChangeEventHandler schemaChangedHandler = new CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)] + public Order_DetailsDataTable Order_Details + { + get + { + return this.tableOrder_Details; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)] + public OrdersDataTable Orders + { + get + { + return this.tableOrders; + } + } + + public override DataSet Clone() + { + myTypedDataSet cln = ((myTypedDataSet)(base.Clone())); + cln.InitVars(); + return cln; + } + + protected override bool ShouldSerializeTables() + { + return false; + } + + protected override bool ShouldSerializeRelations() + { + return false; + } + + protected override void ReadXmlSerializable(XmlReader reader) + { + this.Reset(); + DataSet ds = new DataSet(); + ds.ReadXml(reader); + if ((ds.Tables["Order Details"] != null)) + { + this.Tables.Add(new Order_DetailsDataTable(ds.Tables["Order Details"])); + } + if ((ds.Tables["Orders"] != null)) + { + this.Tables.Add(new OrdersDataTable(ds.Tables["Orders"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, MissingSchemaAction.Add); + this.InitVars(); + } + + protected override XmlSchema GetSchemaSerializable() + { + MemoryStream stream = new MemoryStream(); + this.WriteXmlSchema(new XmlTextWriter(stream, null)); + stream.Position = 0; + return XmlSchema.Read(new XmlTextReader(stream), null); + } + + internal void InitVars() + { + this.tableOrder_Details = ((Order_DetailsDataTable)(this.Tables["Order Details"])); + if ((this.tableOrder_Details != null)) + { + this.tableOrder_Details.InitVars(); + } + this.tableOrders = ((OrdersDataTable)(this.Tables["Orders"])); + if ((this.tableOrders != null)) + { + this.tableOrders.InitVars(); + } + this.relationOrdersOrder_x0020_Details = this.Relations["OrdersOrder_x0020_Details"]; + } + + private void InitClass() + { + this.DataSetName = "myTypedDataSet"; + this.Prefix = ""; + this.Namespace = "http://www.tempuri.org/myTypedDataSet.xsd"; + this.Locale = new CultureInfo("en-US"); + this.CaseSensitive = false; + this.EnforceConstraints = true; + this.tableOrder_Details = new Order_DetailsDataTable(); + this.Tables.Add(this.tableOrder_Details); + this.tableOrders = new OrdersDataTable(); + this.Tables.Add(this.tableOrders); + ForeignKeyConstraint fkc; + fkc = new ForeignKeyConstraint("OrdersOrder_x0020_Details", new DataColumn[] { + this.tableOrders.OrderIDColumn}, new DataColumn[] { + this.tableOrder_Details.OrderIDColumn}); + this.tableOrder_Details.Constraints.Add(fkc); + fkc.AcceptRejectRule = AcceptRejectRule.None; + fkc.DeleteRule = Rule.Cascade; + fkc.UpdateRule = Rule.Cascade; + this.relationOrdersOrder_x0020_Details = new DataRelation("OrdersOrder_x0020_Details", new DataColumn[] { + this.tableOrders.OrderIDColumn}, new DataColumn[] { + this.tableOrder_Details.OrderIDColumn}, false); + this.Relations.Add(this.relationOrdersOrder_x0020_Details); + } + + private bool ShouldSerializeOrder_Details() + { + return false; + } + + private bool ShouldSerializeOrders() + { + return false; + } + + private void SchemaChanged(object sender, CollectionChangeEventArgs e) + { + if ((e.Action == CollectionChangeAction.Remove)) + { + this.InitVars(); + } + } + + public delegate void Order_DetailsRowChangeEventHandler(object sender, Order_DetailsRowChangeEvent e); + + public delegate void OrdersRowChangeEventHandler(object sender, OrdersRowChangeEvent e); + + public class Order_DetailsDataTable : DataTable, IEnumerable + { + + private DataColumn columnOrderID; + + private DataColumn columnProductID; + + private DataColumn columnUnitPrice; + + private DataColumn columnQuantity; + + private DataColumn columnDiscount; + + internal Order_DetailsDataTable() : + base("Order Details") + { + this.InitClass(); + } + + internal Order_DetailsDataTable(DataTable table) : + base(table.TableName) + { + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) + { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) + { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) + { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + this.DisplayExpression = table.DisplayExpression; + } + + [Browsable(false)] + public int Count + { + get + { + return this.Rows.Count; + } + } + + internal DataColumn OrderIDColumn + { + get + { + return this.columnOrderID; + } + } + + internal DataColumn ProductIDColumn + { + get + { + return this.columnProductID; + } + } + + internal DataColumn UnitPriceColumn + { + get + { + return this.columnUnitPrice; + } + } + + internal DataColumn QuantityColumn + { + get + { + return this.columnQuantity; + } + } + + internal DataColumn DiscountColumn + { + get + { + return this.columnDiscount; + } + } + + public Order_DetailsRow this[int index] + { + get + { + return ((Order_DetailsRow)(this.Rows[index])); + } + } + + public event Order_DetailsRowChangeEventHandler Order_DetailsRowChanged; + + public event Order_DetailsRowChangeEventHandler Order_DetailsRowChanging; + + public event Order_DetailsRowChangeEventHandler Order_DetailsRowDeleted; + + public event Order_DetailsRowChangeEventHandler Order_DetailsRowDeleting; + + public void AddOrder_DetailsRow(Order_DetailsRow row) + { + this.Rows.Add(row); + } + + public Order_DetailsRow AddOrder_DetailsRow(OrdersRow parentOrdersRowByOrdersOrder_x0020_Details, int ProductID, Decimal UnitPrice, short Quantity, string Discount) + { + Order_DetailsRow rowOrder_DetailsRow = ((Order_DetailsRow)(this.NewRow())); + rowOrder_DetailsRow.ItemArray = new object[] { + parentOrdersRowByOrdersOrder_x0020_Details[0], + ProductID, + UnitPrice, + Quantity, + Discount}; + this.Rows.Add(rowOrder_DetailsRow); + return rowOrder_DetailsRow; + } + + public Order_DetailsRow FindByOrderIDProductID(int OrderID, int ProductID) + { + return ((Order_DetailsRow)(this.Rows.Find(new object[] { + OrderID, + ProductID}))); + } + + public IEnumerator GetEnumerator() + { + return this.Rows.GetEnumerator(); + } + + public override DataTable Clone() + { + Order_DetailsDataTable cln = ((Order_DetailsDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + protected override DataTable CreateInstance() + { + return new Order_DetailsDataTable(); + } + + internal void InitVars() + { + this.columnOrderID = this.Columns["OrderID"]; + this.columnProductID = this.Columns["ProductID"]; + this.columnUnitPrice = this.Columns["UnitPrice"]; + this.columnQuantity = this.Columns["Quantity"]; + this.columnDiscount = this.Columns["Discount"]; + } + + private void InitClass() + { + this.columnOrderID = new DataColumn("OrderID", typeof(int), null, MappingType.Element); + this.Columns.Add(this.columnOrderID); + this.columnProductID = new DataColumn("ProductID", typeof(int), null, MappingType.Element); + this.Columns.Add(this.columnProductID); + this.columnUnitPrice = new DataColumn("UnitPrice", typeof(Decimal), null, MappingType.Element); + this.Columns.Add(this.columnUnitPrice); + this.columnQuantity = new DataColumn("Quantity", typeof(short), null, MappingType.Element); + this.Columns.Add(this.columnQuantity); + this.columnDiscount = new DataColumn("Discount", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnDiscount); + this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] { + this.columnOrderID, + this.columnProductID}, true)); + this.columnOrderID.AllowDBNull = false; + this.columnProductID.AllowDBNull = false; + this.columnUnitPrice.AllowDBNull = false; + this.columnQuantity.AllowDBNull = false; + this.columnDiscount.ReadOnly = true; + } + + public Order_DetailsRow NewOrder_DetailsRow() + { + return ((Order_DetailsRow)(this.NewRow())); + } + + protected override DataRow NewRowFromBuilder(DataRowBuilder builder) + { + return new Order_DetailsRow(builder); + } + + protected override Type GetRowType() + { + return typeof(Order_DetailsRow); + } + + protected override void OnRowChanged(DataRowChangeEventArgs e) + { + base.OnRowChanged(e); + if ((this.Order_DetailsRowChanged != null)) + { + this.Order_DetailsRowChanged(this, new Order_DetailsRowChangeEvent(((Order_DetailsRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowChanging(DataRowChangeEventArgs e) + { + base.OnRowChanging(e); + if ((this.Order_DetailsRowChanging != null)) + { + this.Order_DetailsRowChanging(this, new Order_DetailsRowChangeEvent(((Order_DetailsRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowDeleted(DataRowChangeEventArgs e) + { + base.OnRowDeleted(e); + if ((this.Order_DetailsRowDeleted != null)) + { + this.Order_DetailsRowDeleted(this, new Order_DetailsRowChangeEvent(((Order_DetailsRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowDeleting(DataRowChangeEventArgs e) + { + base.OnRowDeleting(e); + if ((this.Order_DetailsRowDeleting != null)) + { + this.Order_DetailsRowDeleting(this, new Order_DetailsRowChangeEvent(((Order_DetailsRow)(e.Row)), e.Action)); + } + } + + public void RemoveOrder_DetailsRow(Order_DetailsRow row) + { + this.Rows.Remove(row); + } + } + + public class Order_DetailsRow : DataRow + { + + private Order_DetailsDataTable tableOrder_Details; + + internal Order_DetailsRow(DataRowBuilder rb) : + base(rb) + { + this.tableOrder_Details = ((Order_DetailsDataTable)(this.Table)); + } + + public int OrderID + { + get + { + return ((int)(this[this.tableOrder_Details.OrderIDColumn])); + } + set + { + this[this.tableOrder_Details.OrderIDColumn] = value; + } + } + + public int ProductID + { + get + { + return ((int)(this[this.tableOrder_Details.ProductIDColumn])); + } + set + { + this[this.tableOrder_Details.ProductIDColumn] = value; + } + } + + public Decimal UnitPrice + { + get + { + return ((Decimal)(this[this.tableOrder_Details.UnitPriceColumn])); + } + set + { + this[this.tableOrder_Details.UnitPriceColumn] = value; + } + } + + public short Quantity + { + get + { + return ((short)(this[this.tableOrder_Details.QuantityColumn])); + } + set + { + this[this.tableOrder_Details.QuantityColumn] = value; + } + } + + public string Discount + { + get + { + try + { + return ((string)(this[this.tableOrder_Details.DiscountColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrder_Details.DiscountColumn] = value; + } + } + + public OrdersRow OrdersRow + { + get + { + return ((OrdersRow)(this.GetParentRow(this.Table.ParentRelations["OrdersOrder_x0020_Details"]))); + } + set + { + this.SetParentRow(value, this.Table.ParentRelations["OrdersOrder_x0020_Details"]); + } + } + + public bool IsDiscountNull() + { + return this.IsNull(this.tableOrder_Details.DiscountColumn); + } + + public void SetDiscountNull() + { + this[this.tableOrder_Details.DiscountColumn] = Convert.DBNull; + } + } + + public class Order_DetailsRowChangeEvent : EventArgs + { + + private Order_DetailsRow eventRow; + + private DataRowAction eventAction; + + public Order_DetailsRowChangeEvent(Order_DetailsRow row, DataRowAction action) + { + this.eventRow = row; + this.eventAction = action; + } + + public Order_DetailsRow Row + { + get + { + return this.eventRow; + } + } + + public DataRowAction Action + { + get + { + return this.eventAction; + } + } + } + + public class OrdersDataTable : DataTable, IEnumerable + { + + private DataColumn columnOrderID; + + private DataColumn columnCustomerID; + + private DataColumn columnEmployeeID; + + private DataColumn columnOrderDate; + + private DataColumn columnRequiredDate; + + private DataColumn columnShippedDate; + + private DataColumn columnShipVia; + + private DataColumn columnFreight; + + private DataColumn columnShipName; + + private DataColumn columnShipAddress; + + private DataColumn columnShipCity; + + private DataColumn columnShipRegion; + + private DataColumn columnShipPostalCode; + + private DataColumn columnShipCountry; + + internal OrdersDataTable() : + base("Orders") + { + this.InitClass(); + } + + internal OrdersDataTable(DataTable table) : + base(table.TableName) + { + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) + { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) + { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) + { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + this.DisplayExpression = table.DisplayExpression; + } + + [Browsable(false)] + public int Count + { + get + { + return this.Rows.Count; + } + } + + internal DataColumn OrderIDColumn + { + get + { + return this.columnOrderID; + } + } + + internal DataColumn CustomerIDColumn + { + get + { + return this.columnCustomerID; + } + } + + internal DataColumn EmployeeIDColumn + { + get + { + return this.columnEmployeeID; + } + } + + internal DataColumn OrderDateColumn + { + get + { + return this.columnOrderDate; + } + } + + internal DataColumn RequiredDateColumn + { + get + { + return this.columnRequiredDate; + } + } + + internal DataColumn ShippedDateColumn + { + get + { + return this.columnShippedDate; + } + } + + internal DataColumn ShipViaColumn + { + get + { + return this.columnShipVia; + } + } + + internal DataColumn FreightColumn + { + get + { + return this.columnFreight; + } + } + + internal DataColumn ShipNameColumn + { + get + { + return this.columnShipName; + } + } + + internal DataColumn ShipAddressColumn + { + get + { + return this.columnShipAddress; + } + } + + internal DataColumn ShipCityColumn + { + get + { + return this.columnShipCity; + } + } + + internal DataColumn ShipRegionColumn + { + get + { + return this.columnShipRegion; + } + } + + internal DataColumn ShipPostalCodeColumn + { + get + { + return this.columnShipPostalCode; + } + } + + internal DataColumn ShipCountryColumn + { + get + { + return this.columnShipCountry; + } + } + + public OrdersRow this[int index] + { + get + { + return ((OrdersRow)(this.Rows[index])); + } + } + + public event OrdersRowChangeEventHandler OrdersRowChanged; + + public event OrdersRowChangeEventHandler OrdersRowChanging; + + public event OrdersRowChangeEventHandler OrdersRowDeleted; + + public event OrdersRowChangeEventHandler OrdersRowDeleting; + + public void AddOrdersRow(OrdersRow row) + { + this.Rows.Add(row); + } + + public OrdersRow AddOrdersRow(string CustomerID, int EmployeeID, DateTime OrderDate, DateTime RequiredDate, DateTime ShippedDate, int ShipVia, Decimal Freight, string ShipName, string ShipAddress, string ShipCity, string ShipRegion, string ShipPostalCode, string ShipCountry) + { + OrdersRow rowOrdersRow = ((OrdersRow)(this.NewRow())); + rowOrdersRow.ItemArray = new object[] { + null, + CustomerID, + EmployeeID, + OrderDate, + RequiredDate, + ShippedDate, + ShipVia, + Freight, + ShipName, + ShipAddress, + ShipCity, + ShipRegion, + ShipPostalCode, + ShipCountry}; + this.Rows.Add(rowOrdersRow); + return rowOrdersRow; + } + + public OrdersRow FindByOrderID(int OrderID) + { + return ((OrdersRow)(this.Rows.Find(new object[] { + OrderID}))); + } + + public IEnumerator GetEnumerator() + { + return this.Rows.GetEnumerator(); + } + + public override DataTable Clone() + { + OrdersDataTable cln = ((OrdersDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + protected override DataTable CreateInstance() + { + return new OrdersDataTable(); + } + + internal void InitVars() + { + this.columnOrderID = this.Columns["OrderID"]; + this.columnCustomerID = this.Columns["CustomerID"]; + this.columnEmployeeID = this.Columns["EmployeeID"]; + this.columnOrderDate = this.Columns["OrderDate"]; + this.columnRequiredDate = this.Columns["RequiredDate"]; + this.columnShippedDate = this.Columns["ShippedDate"]; + this.columnShipVia = this.Columns["ShipVia"]; + this.columnFreight = this.Columns["Freight"]; + this.columnShipName = this.Columns["ShipName"]; + this.columnShipAddress = this.Columns["ShipAddress"]; + this.columnShipCity = this.Columns["ShipCity"]; + this.columnShipRegion = this.Columns["ShipRegion"]; + this.columnShipPostalCode = this.Columns["ShipPostalCode"]; + this.columnShipCountry = this.Columns["ShipCountry"]; + } + + private void InitClass() + { + this.columnOrderID = new DataColumn("OrderID", typeof(int), null, MappingType.Element); + this.Columns.Add(this.columnOrderID); + this.columnCustomerID = new DataColumn("CustomerID", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnCustomerID); + this.columnEmployeeID = new DataColumn("EmployeeID", typeof(int), null, MappingType.Element); + this.Columns.Add(this.columnEmployeeID); + this.columnOrderDate = new DataColumn("OrderDate", typeof(DateTime), null, MappingType.Element); + this.Columns.Add(this.columnOrderDate); + this.columnRequiredDate = new DataColumn("RequiredDate", typeof(DateTime), null, MappingType.Element); + this.Columns.Add(this.columnRequiredDate); + this.columnShippedDate = new DataColumn("ShippedDate", typeof(DateTime), null, MappingType.Element); + this.Columns.Add(this.columnShippedDate); + this.columnShipVia = new DataColumn("ShipVia", typeof(int), null, MappingType.Element); + this.Columns.Add(this.columnShipVia); + this.columnFreight = new DataColumn("Freight", typeof(Decimal), null, MappingType.Element); + this.Columns.Add(this.columnFreight); + this.columnShipName = new DataColumn("ShipName", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipName); + this.columnShipAddress = new DataColumn("ShipAddress", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipAddress); + this.columnShipCity = new DataColumn("ShipCity", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipCity); + this.columnShipRegion = new DataColumn("ShipRegion", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipRegion); + this.columnShipPostalCode = new DataColumn("ShipPostalCode", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipPostalCode); + this.columnShipCountry = new DataColumn("ShipCountry", typeof(string), null, MappingType.Element); + this.Columns.Add(this.columnShipCountry); + this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] { + this.columnOrderID}, true)); + this.columnOrderID.AutoIncrement = true; + this.columnOrderID.AllowDBNull = false; + this.columnOrderID.ReadOnly = true; + this.columnOrderID.Unique = true; + } + + public OrdersRow NewOrdersRow() + { + return ((OrdersRow)(this.NewRow())); + } + + protected override DataRow NewRowFromBuilder(DataRowBuilder builder) + { + return new OrdersRow(builder); + } + + protected override Type GetRowType() + { + return typeof(OrdersRow); + } + + protected override void OnRowChanged(DataRowChangeEventArgs e) + { + base.OnRowChanged(e); + if ((this.OrdersRowChanged != null)) + { + this.OrdersRowChanged(this, new OrdersRowChangeEvent(((OrdersRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowChanging(DataRowChangeEventArgs e) + { + base.OnRowChanging(e); + if ((this.OrdersRowChanging != null)) + { + this.OrdersRowChanging(this, new OrdersRowChangeEvent(((OrdersRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowDeleted(DataRowChangeEventArgs e) + { + base.OnRowDeleted(e); + if ((this.OrdersRowDeleted != null)) + { + this.OrdersRowDeleted(this, new OrdersRowChangeEvent(((OrdersRow)(e.Row)), e.Action)); + } + } + + protected override void OnRowDeleting(DataRowChangeEventArgs e) + { + base.OnRowDeleting(e); + if ((this.OrdersRowDeleting != null)) + { + this.OrdersRowDeleting(this, new OrdersRowChangeEvent(((OrdersRow)(e.Row)), e.Action)); + } + } + + public void RemoveOrdersRow(OrdersRow row) + { + this.Rows.Remove(row); + } + } + + public class OrdersRow : DataRow + { + + private OrdersDataTable tableOrders; + + internal OrdersRow(DataRowBuilder rb) : + base(rb) + { + this.tableOrders = ((OrdersDataTable)(this.Table)); + } + + public int OrderID + { + get + { + return ((int)(this[this.tableOrders.OrderIDColumn])); + } + set + { + this[this.tableOrders.OrderIDColumn] = value; + } + } + + public string CustomerID + { + get + { + try + { + return ((string)(this[this.tableOrders.CustomerIDColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.CustomerIDColumn] = value; + } + } + + public int EmployeeID + { + get + { + try + { + return ((int)(this[this.tableOrders.EmployeeIDColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.EmployeeIDColumn] = value; + } + } + + public DateTime OrderDate + { + get + { + try + { + return ((DateTime)(this[this.tableOrders.OrderDateColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.OrderDateColumn] = value; + } + } + + public DateTime RequiredDate + { + get + { + try + { + return ((DateTime)(this[this.tableOrders.RequiredDateColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.RequiredDateColumn] = value; + } + } + + public DateTime ShippedDate + { + get + { + try + { + return ((DateTime)(this[this.tableOrders.ShippedDateColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShippedDateColumn] = value; + } + } + + public int ShipVia + { + get + { + try + { + return ((int)(this[this.tableOrders.ShipViaColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipViaColumn] = value; + } + } + + public Decimal Freight + { + get + { + try + { + return ((Decimal)(this[this.tableOrders.FreightColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.FreightColumn] = value; + } + } + + public string ShipName + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipNameColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipNameColumn] = value; + } + } + + public string ShipAddress + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipAddressColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipAddressColumn] = value; + } + } + + public string ShipCity + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipCityColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipCityColumn] = value; + } + } + + public string ShipRegion + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipRegionColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipRegionColumn] = value; + } + } + + public string ShipPostalCode + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipPostalCodeColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipPostalCodeColumn] = value; + } + } + + public string ShipCountry + { + get + { + try + { + return ((string)(this[this.tableOrders.ShipCountryColumn])); + } + catch (InvalidCastException e) + { + throw new StrongTypingException("Cannot get value because it is DBNull.", e); + } + } + set + { + this[this.tableOrders.ShipCountryColumn] = value; + } + } + + public bool IsCustomerIDNull() + { + return this.IsNull(this.tableOrders.CustomerIDColumn); + } + + public void SetCustomerIDNull() + { + this[this.tableOrders.CustomerIDColumn] = Convert.DBNull; + } + + public bool IsEmployeeIDNull() + { + return this.IsNull(this.tableOrders.EmployeeIDColumn); + } + + public void SetEmployeeIDNull() + { + this[this.tableOrders.EmployeeIDColumn] = Convert.DBNull; + } + + public bool IsOrderDateNull() + { + return this.IsNull(this.tableOrders.OrderDateColumn); + } + + public void SetOrderDateNull() + { + this[this.tableOrders.OrderDateColumn] = Convert.DBNull; + } + + public bool IsRequiredDateNull() + { + return this.IsNull(this.tableOrders.RequiredDateColumn); + } + + public void SetRequiredDateNull() + { + this[this.tableOrders.RequiredDateColumn] = Convert.DBNull; + } + + public bool IsShippedDateNull() + { + return this.IsNull(this.tableOrders.ShippedDateColumn); + } + + public void SetShippedDateNull() + { + this[this.tableOrders.ShippedDateColumn] = Convert.DBNull; + } + + public bool IsShipViaNull() + { + return this.IsNull(this.tableOrders.ShipViaColumn); + } + + public void SetShipViaNull() + { + this[this.tableOrders.ShipViaColumn] = Convert.DBNull; + } + + public bool IsFreightNull() + { + return this.IsNull(this.tableOrders.FreightColumn); + } + + public void SetFreightNull() + { + this[this.tableOrders.FreightColumn] = Convert.DBNull; + } + + public bool IsShipNameNull() + { + return this.IsNull(this.tableOrders.ShipNameColumn); + } + + public void SetShipNameNull() + { + this[this.tableOrders.ShipNameColumn] = Convert.DBNull; + } + + public bool IsShipAddressNull() + { + return this.IsNull(this.tableOrders.ShipAddressColumn); + } + + public void SetShipAddressNull() + { + this[this.tableOrders.ShipAddressColumn] = Convert.DBNull; + } + + public bool IsShipCityNull() + { + return this.IsNull(this.tableOrders.ShipCityColumn); + } + + public void SetShipCityNull() + { + this[this.tableOrders.ShipCityColumn] = Convert.DBNull; + } + + public bool IsShipRegionNull() + { + return this.IsNull(this.tableOrders.ShipRegionColumn); + } + + public void SetShipRegionNull() + { + this[this.tableOrders.ShipRegionColumn] = Convert.DBNull; + } + + public bool IsShipPostalCodeNull() + { + return this.IsNull(this.tableOrders.ShipPostalCodeColumn); + } + + public void SetShipPostalCodeNull() + { + this[this.tableOrders.ShipPostalCodeColumn] = Convert.DBNull; + } + + public bool IsShipCountryNull() + { + return this.IsNull(this.tableOrders.ShipCountryColumn); + } + + public void SetShipCountryNull() + { + this[this.tableOrders.ShipCountryColumn] = Convert.DBNull; + } + + public Order_DetailsRow[] GetOrder_DetailsRows() + { + return ((Order_DetailsRow[])(this.GetChildRows(this.Table.ChildRelations["OrdersOrder_x0020_Details"]))); + } + } + + public class OrdersRowChangeEvent : EventArgs + { + + private OrdersRow eventRow; + + private DataRowAction eventAction; + + public OrdersRowChangeEvent(OrdersRow row, DataRowAction action) + { + this.eventRow = row; + this.eventAction = action; + } + + public OrdersRow Row + { + get + { + return this.eventRow; + } + } + + public DataRowAction Action + { + get + { + return this.eventAction; + } + } + } + } + } +} diff --git a/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest2.cs b/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest2.cs index e3bcb15bd7e..ec1db6f389c 100644 --- a/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest2.cs @@ -287,5 +287,196 @@ namespace MonoTests_System.Data Assert.AreEqual(dt, ds.Tables["NewTable1"], "DTC41"); Assert.AreEqual(dt1, ds.Tables["NewTable2"], "DTC42"); } + + [Test]
+ public void DataTableCollection_Add_D1()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("NewTable1");
+ ds.Tables.Add(dt);
+ Assert.AreEqual("NewTable1",ds.Tables[0].TableName,"DTC43");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void DataTableCollection_Add_D2()
+ {
+ DataSet ds = new DataSet();
+
+ ds.Tables.Add((DataTable)null);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void DataTableCollection_Add_D3()
+ {
+ DataSet ds = new DataSet();
+ DataSet ds1 = new DataSet();
+ ds1.Tables.Add();
+
+ ds.Tables.Add(ds1.Tables[0]);
+ }
+
+ [Test]
+ [ExpectedException(typeof(DuplicateNameException))]
+ public void DataTableCollection_Add_D4()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add();
+
+ DataTable dt = new DataTable("Table1");
+ ds.Tables.Add(dt);
+ } + + [Test]
+ public void DataTableCollection_Add_S1()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add("NewTable1");
+ Assert.AreEqual("NewTable1",ds.Tables[0].TableName,"DTC44");
+ ds.Tables.Add("NewTable2");
+ Assert.AreEqual("NewTable2",ds.Tables[1].TableName,"DTC45");
+ }
+
+ [Test]
+ [ExpectedException(typeof(DuplicateNameException))]
+ public void DataTableCollection_Add_S2()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add("NewTable1");
+
+ ds.Tables.Add("NewTable1");
+ } + + [Test]
+ public void DataTableCollection_Clear1()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add();
+ ds.Tables.Add();
+ ds.Tables.Clear();
+ Assert.AreEqual(0,ds.Tables.Count,"DTC46");
+
+ }
+
+ [Test]
+ [ExpectedException(typeof(IndexOutOfRangeException))]
+ public void DataTableCollection_Clear2()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add();
+ ds.Tables.Add();
+ ds.Tables.Clear();
+
+ ds.Tables[0].TableName = "Error";
+ } + + [Test]
+ public void DataTableCollection_Remove_D1()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("NewTable1");
+ DataTable dt1 = new DataTable("NewTable2");
+ ds.Tables.AddRange(new DataTable[] {dt,dt1});
+
+ ds.Tables.Remove(dt);
+ Assert.AreEqual(1,ds.Tables.Count,"DTC47");
+ Assert.AreEqual(dt1,ds.Tables[0],"DTC48");
+ ds.Tables.Remove(dt1);
+ Assert.AreEqual(0,ds.Tables.Count,"DTC49");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void DataTableCollection_Remove_D2()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("NewTable1");
+
+ ds.Tables.Remove(dt);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void DataTableCollection_Remove_D3()
+ {
+ DataSet ds = new DataSet();
+
+ ds.Tables.Remove((DataTable)null);
+ } + + [Test]
+ public void DataTableCollection_Remove_S1()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("NewTable1");
+ DataTable dt1 = new DataTable("NewTable2");
+ ds.Tables.AddRange(new DataTable[] {dt,dt1});
+
+ ds.Tables.Remove("NewTable1");
+ Assert.AreEqual(1,ds.Tables.Count,"DTC50");
+ Assert.AreEqual(dt1,ds.Tables[0],"DTC51");
+ ds.Tables.Remove("NewTable2");
+ Assert.AreEqual(0,ds.Tables.Count,"DTC52");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void DataTableCollection_Remove_S2()
+ {
+ DataSet ds = new DataSet();
+
+ ds.Tables.Remove("NewTable2");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void DataTableCollection_Remove_S3()
+ {
+ DataSet ds = new DataSet();
+
+ ds.Tables.Remove((string)null);
+ } + + [Test]
+ public void DataTableCollection_RemoveAt_I1()
+ {
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("NewTable1");
+ DataTable dt1 = new DataTable("NewTable2");
+ ds.Tables.AddRange(new DataTable[] {dt,dt1});
+
+ ds.Tables.RemoveAt(1);
+ Assert.AreEqual(dt,ds.Tables[0],"DTC53");
+ ds.Tables.RemoveAt(0);
+ Assert.AreEqual(0,ds.Tables.Count,"DTC54");
+ }
+
+ [Test]
+ [ExpectedException(typeof(IndexOutOfRangeException))]
+ public void DataTableCollection_RemoveAt_I2()
+ {
+ DataSet ds = new DataSet();
+
+ ds.Tables.RemoveAt(-1);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void DataTableCollection_RemoveAt_I3()
+ {
+ DataSet ds = DataProvider.CreateForigenConstraint();
+
+ ds.Tables.RemoveAt(0); //Parent table
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataTableTest2.cs b/mcs/class/System.Data/Test/System.Data/DataTableTest2.cs index 9dc709bb630..73c5952a9b6 100644 --- a/mcs/class/System.Data/Test/System.Data/DataTableTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataTableTest2.cs @@ -69,6 +69,26 @@ namespace MonoTests_System.Data { return CreateInstance(); } + + public void OnRowChanged_Test(DataRowAction drAction )
+ {
+ base.OnRowChanged(new DataRowChangeEventArgs(this.Rows[0],drAction ));
+ } + + public void OnRowChanging_Test(DataRowAction drAction )
+ {
+ base.OnRowChanging(new DataRowChangeEventArgs(this.Rows[0],drAction ));
+ } + + public void OnRowDeleted_Test(DataRowAction drAction )
+ {
+ base.OnRowDeleted(new DataRowChangeEventArgs(this.Rows[0],drAction ));
+ } + + public void OnRowDeleting_Test(DataRowAction drAction )
+ {
+ base.OnRowDeleting(new DataRowChangeEventArgs(this.Rows[0],drAction ));
+ } } [Test] public void AcceptChanges() @@ -1642,5 +1662,408 @@ namespace MonoTests_System.Data Assert.AreEqual ("7.5", table.Compute ("Max(Value)",String.Empty),"#4"); } + + [Test] + public void BeginLoadData()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ dt.Columns[0].AllowDBNull = false;
+
+ //dt.BeginLoadData();
+ try
+ {
+ //if BeginLoadData has not been called, an exception will be throw
+ dt.LoadDataRow(new object[] {null,"A","B"},false);
+ Assert.Fail("DT170: Failed to throw NoNullAllowedException"); + } + catch (NoNullAllowedException) {} + catch (AssertionException exc) {throw exc;} + catch (Exception exc) + { + Assert.Fail("DT171: Wrong exception type. Got:" + exc); + }
+
+
+ DataTable dt1 = DataProvider.CreateUniqueConstraint();
+
+ bool excptionOccurd = false;
+
+ try
+ {
+ dt1.BeginLoadData();
+
+ DataRow dr = dt1.NewRow();
+ dr[0] = 3;
+ dt1.Rows.Add(dr);
+ dt1.EndLoadData(); // constraint violation
+
+ Assert.Fail("DT172: Failed to throw ConstraintException"); + } + catch (ConstraintException) + { + Assert.AreEqual(2,dt1.GetErrors().Length,"DT173");
+ Assert.AreEqual(true,dt1.GetErrors()[0].RowError.Length > 10,"DT174");
+ Assert.AreEqual(true,dt1.GetErrors()[1].RowError.Length > 10,"DT175"); + } + catch (AssertionException exc) {throw exc;} + catch (Exception exc) + { + Assert.Fail("DT176: Wrong exception type. Got:" + exc); + }
+
+
+ DataSet ds=null;
+ excptionOccurd = false;
+ try
+ {
+ ds= DataProvider.CreateForigenConstraint();
+ ds.Tables[0].BeginLoadData();
+ ds.Tables[0].Rows[0][0] = 10; //Forigen constraint violation
+ //ds.Tables[0].AcceptChanges();
+ ds.Tables[0].EndLoadData();
+
+ Assert.Fail("DT177: Failed to throw ConstraintException"); + } + catch (ConstraintException) + { + Assert.AreEqual(3,ds.Tables[1].GetErrors().Length,"DT178");
+ for(int index=0;index<3;index++)
+ {
+ Assert.AreEqual(true,ds.Tables[1].GetErrors()[index].RowError.Length > 10,"DT179");
+ } + } + catch (AssertionException exc) {throw exc;} + catch (Exception exc) + { + Assert.Fail("DT180: Wrong exception type. Got:" + exc); + }
+ } +
+ private DataRowAction drExpectedAction;
+
+ public void OnRowChanged()
+ {
+ ProtectedTestClass dt = new ProtectedTestClass();
+
+ EventRaised = false;
+ dt.OnRowChanged_Test(DataRowAction.Nothing );
+
+ Assert.IsFalse(EventRaised ,"DT181" );
+
+ dt.RowChanged += new DataRowChangeEventHandler(OnRowChanged_Handler);
+ foreach (int i in Enum.GetValues(typeof(DataRowAction)))
+ {
+ EventRaised = false;
+ EventValues = false;
+ drExpectedAction = (DataRowAction)i;
+ dt.OnRowChanged_Test(drExpectedAction);
+
+ Assert.IsTrue(EventRaised ,"DT182" );
+
+ Assert.IsTrue(EventValues ,"DT183" );
+ }
+ dt.RowChanged -= new DataRowChangeEventHandler(OnRowChanged_Handler);
+ }
+
+ private void OnRowChanged_Handler(Object sender,DataRowChangeEventArgs e)
+ {
+
+ DataTable dt = (DataTable)sender;
+ if (dt.Rows[0].Equals(e.Row) && e.Action == drExpectedAction)
+ EventValues = true;
+ EventRaised = true;
+ } + + [Test] + public void OnRowChanging()
+ {
+ ProtectedTestClass dt = new ProtectedTestClass();
+
+ EventRaised = false;
+ dt.OnRowChanging_Test(DataRowAction.Nothing );
+
+ Assert.IsFalse(EventRaised ,"DT184" );
+
+ dt.RowChanging += new DataRowChangeEventHandler(OnRowChanging_Handler);
+ foreach (int i in Enum.GetValues(typeof(DataRowAction)))
+ {
+ EventRaised = false;
+ EventValues = false;
+ drExpectedAction = (DataRowAction)i;
+ dt.OnRowChanging_Test(drExpectedAction);
+
+ Assert.IsTrue(EventRaised ,"DT185" );
+
+ Assert.IsTrue(EventValues ,"DT186" );
+ }
+ dt.RowChanging -= new DataRowChangeEventHandler(OnRowChanging_Handler);
+ }
+
+ private void OnRowChanging_Handler(Object sender,DataRowChangeEventArgs e)
+ {
+
+ DataTable dt = (DataTable)sender;
+ if (dt.Rows[0].Equals(e.Row) && e.Action == drExpectedAction)
+ EventValues = true;
+ EventRaised = true;
+ } + + [Test] + public void OnRowDeleted()
+ {
+ ProtectedTestClass dt = new ProtectedTestClass();
+
+ EventRaised = false;
+ dt.OnRowDeleted_Test(DataRowAction.Nothing );
+
+ Assert.IsFalse(EventRaised ,"DT187" );
+
+ dt.RowDeleted += new DataRowChangeEventHandler(OnRowDeleted_Handler);
+ foreach (int i in Enum.GetValues(typeof(DataRowAction)))
+ {
+ EventRaised = false;
+ EventValues = false;
+ drExpectedAction = (DataRowAction)i;
+ dt.OnRowDeleted_Test(drExpectedAction);
+
+ Assert.IsTrue(EventRaised ,"DT188" );
+
+ Assert.IsTrue(EventValues ,"DT189" );
+ }
+ dt.RowDeleted -= new DataRowChangeEventHandler(OnRowDeleted_Handler);
+ }
+
+
+ private void OnRowDeleted_Handler(Object sender,DataRowChangeEventArgs e)
+ {
+ DataTable dt = (DataTable)sender;
+ if (dt.Rows[0].Equals(e.Row) && e.Action == drExpectedAction)
+ EventValues = true;
+ EventRaised = true;
+ } + + public void OnRowDeleting()
+ {
+ ProtectedTestClass dt = new ProtectedTestClass();
+
+ EventRaised = false;
+ dt.OnRowDeleting_Test(DataRowAction.Nothing );
+
+ Assert.IsFalse(EventRaised ,"DT190" );
+
+ dt.RowDeleting += new DataRowChangeEventHandler(OnRowDeleting_Handler);
+ foreach (int i in Enum.GetValues(typeof(DataRowAction)))
+ {
+ EventRaised = false;
+ EventValues = false;
+ drExpectedAction = (DataRowAction)i;
+ dt.OnRowDeleting_Test(drExpectedAction);
+
+ Assert.IsTrue(EventRaised ,"DT191" );
+
+ Assert.IsTrue(EventValues ,"DT192" );
+ }
+ dt.RowDeleting -= new DataRowChangeEventHandler(OnRowDeleting_Handler);
+ }
+
+ private void OnRowDeleting_Handler(Object sender,DataRowChangeEventArgs e)
+ {
+
+ DataTable dt = (DataTable)sender;
+ if (dt.Rows[0].Equals(e.Row) && e.Action == drExpectedAction)
+ EventValues = true;
+ EventRaised = true;
+ } + + [Test] +#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif + public void Select_StringString()
+ {
+ DataTable dt = DataProvider.CreateChildDataTable();
+
+ DataRow[] drSelect;
+ System.Collections.ArrayList al;
+
+ //add some rows
+ dt.Rows.Add(new object[] {99,88,"bla","wowww"});
+ dt.Rows.Add(new object[] {999,888,"","woowww"});
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if ((int)dr["ChildId"] == 1)
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("ChildId=1","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT193");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if (dr["String1"].ToString() == "1-String1")
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("String1='1-String1'","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT194");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if ((int)dr["ChildId"] == 1 && dr["String1"].ToString() == "1-String1")
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("ChildId=1 and String1='1-String1'","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT195");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if (dr["String1"].ToString().Length < 4 )
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("Len(String1) < 4 ","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT196");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if ( dr["String1"].ToString().IndexOf("String") > 0 )
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("String1 like '%%String*' ","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT197");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if (((int)dr["ChildId"] == 2) || ((int)dr["ChildId"] == 3))
+ al.Add(dr);
+ }
+ //al.Reverse();
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("ChildId in (2,3) ","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT198");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if ((((int)dr["ChildId"] * (int)dr["ParentId"]) > 5 ))
+ al.Add(dr);
+ }
+ al.Sort(new DataRowsComparer("ChildId", "Asc"));
+
+ drSelect = dt.Select("ChildId * ParentId > 5 ","ChildId Asc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT199");
+
+
+ //get excepted resault
+ al = new System.Collections.ArrayList();
+ foreach (DataRow dr in dt.Rows )
+ {
+ if (dr["String2"].ToString().Substring(2,3) == "Str" )
+ al.Add(dr);
+ }
+ al.Sort(new DataRowsComparer("ParentId", "Desc"));
+
+ drSelect = dt.Select("SubString(String2,3,3) like 'Str' ","ParentId Desc");
+ Assert.AreEqual(al.ToArray(),drSelect ,"DT200");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+#if !TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Select_StringString_2()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ //Checking the parsing of the sort string
+ dt.Select(dt.Columns[0].ColumnName + "=1","[x");
+ }
+
+ [Test]
+ [ExpectedException(typeof(IndexOutOfRangeException))]
+ public void Select_StringString_3()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+ //Select - parse sort string checking 1");
+ dt.Select(dt.Columns[0].ColumnName,dt.Columns[0].ColumnName + "1");
+ } + + internal class DataRowsComparer : System.Collections.IComparer
+ {
+ #region Memebers
+ private string _columnName;
+ private string _direction;
+ #endregion
+
+ #region Constructors
+ public DataRowsComparer(string columnName, string direction)
+ {
+ _columnName = columnName;
+ if (direction.ToLower() != "asc" && direction.ToLower() != "desc")
+ {
+ throw new ArgumentException("Direction can only be one of: 'asc' or 'desc'");
+ }
+ _direction = direction;
+ }
+ #endregion
+
+ #region IComparer Members
+
+ public int Compare(object x, object y)
+ {
+ DataRow drX = (DataRow)x;
+ DataRow drY = (DataRow)y;
+
+ object objX = drX[_columnName];
+ object objY = drY[_columnName];
+
+ int compareResult = System.Collections.Comparer.Default.Compare(objX, objY);
+
+ //If we are comparing desc we need to reverse the result.
+ if (_direction.ToLower() == "desc")
+ {
+ compareResult = -compareResult;
+ }
+
+ return compareResult;
+
+ }
+
+ #endregion
+
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataViewTest2.cs b/mcs/class/System.Data/Test/System.Data/DataViewTest2.cs index 83cffa4edc7..ac568329cb2 100644 --- a/mcs/class/System.Data/Test/System.Data/DataViewTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/DataViewTest2.cs @@ -1040,5 +1040,31 @@ namespace MonoTests_System.Data // ctor - RowStateFilter Assert.AreEqual(DataViewRowState.Added , dv.RowStateFilter , "DV113"); } + + [Test] + public void DataViewManager()
+ {
+ DataView dv = null;
+ DataViewManager dvm = null;
+ DataSet ds = new DataSet();
+ DataTable dt = new DataTable("myTable");
+ ds.Tables.Add(dt);
+
+ dv = dt.DefaultView;
+
+ // public DataViewManager DataViewManager {get;} - The DataViewManager that created this view.
+ // If this is the default DataView for a DataTable, the DataViewManager property returns the default DataViewManager for the DataSet.
+ // Otherwise, if the DataView was created without a DataViewManager, this property is a null reference (Nothing in Visual Basic).
+
+ dvm = dv.DataViewManager;
+ Assert.AreEqual(ds.DefaultViewManager,dvm, "DV114");
+
+ dv = new DataView(dt);
+ dvm = dv.DataViewManager;
+ Assert.AreEqual(null,dvm,"DV115");
+
+ dv = ds.DefaultViewManager.CreateDataView(dt);
+ Assert.AreEqual(ds.DefaultViewManager,dv.DataViewManager , "DV116");
+ } } } diff --git a/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest2.cs b/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest2.cs index 02e2256fdf0..f3efd800121 100644 --- a/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest2.cs +++ b/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest2.cs @@ -48,10 +48,10 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // Columns - Assert.AreEqual(dtChild.Columns[0] , fc.Columns[0] , "FKC"); + Assert.AreEqual(dtChild.Columns[0] , fc.Columns[0] , "FKC1"); // Columns count - Assert.AreEqual(1 , fc.Columns.Length , "FKC"); + Assert.AreEqual(1 , fc.Columns.Length , "FKC2"); } [Test] public void Equals() @@ -69,12 +69,12 @@ namespace MonoTests_System.Data fc2 = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[1]); // different columnn - Assert.AreEqual(false, fc1.Equals(fc2), "FKC"); + Assert.AreEqual(false, fc1.Equals(fc2), "FKC3"); //Two System.Data.ForeignKeyConstraint are equal if they constrain the same columns. // same column fc2 = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); - Assert.AreEqual(true, fc1.Equals(fc2), "FKC"); + Assert.AreEqual(true, fc1.Equals(fc2), "FKC4"); } [Test] public void RelatedColumns() @@ -88,7 +88,7 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // RelatedColumns - Assert.AreEqual(new DataColumn[] {dtParent.Columns[0]}, fc.RelatedColumns , "FKC"); + Assert.AreEqual(new DataColumn[] {dtParent.Columns[0]}, fc.RelatedColumns , "FKC5"); } [Test] public void RelatedTable() @@ -102,7 +102,7 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // RelatedTable - Assert.AreEqual(dtParent, fc.RelatedTable , "FKC"); + Assert.AreEqual(dtParent, fc.RelatedTable , "FKC6"); } [Test] public void Table() @@ -116,7 +116,7 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // Table - Assert.AreEqual(dtChild , fc.Table , "FKC"); + Assert.AreEqual(dtChild , fc.Table , "FKC7"); } [Test] public new void ToString() @@ -128,11 +128,11 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // ToString - default - Assert.AreEqual(string.Empty , fc.ToString(), "FKC"); + Assert.AreEqual(string.Empty , fc.ToString(), "FKC8"); fc = new ForeignKeyConstraint("myConstraint",dtParent.Columns[0],dtChild.Columns[0]); // Tostring - Constraint name - Assert.AreEqual("myConstraint", fc.ToString(), "FKC"); + Assert.AreEqual("myConstraint", fc.ToString(), "FKC9"); } [Test] public void acceptRejectRule() @@ -146,9 +146,9 @@ namespace MonoTests_System.Data //Update the parent ds.Tables[0].Rows[0]["ParentId"] = 777; - Assert.AreEqual(true, ds.Tables[1].Select("ParentId=777").Length > 0 , "FKC"); + Assert.AreEqual(true, ds.Tables[1].Select("ParentId=777").Length > 0 , "FKC10"); ds.Tables[0].RejectChanges(); - Assert.AreEqual(0, ds.Tables[1].Select("ParentId=777").Length , "FKC"); + Assert.AreEqual(0, ds.Tables[1].Select("ParentId=777").Length , "FKC11"); } private DataSet getNewDataSet() { @@ -173,12 +173,12 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]); // default - Assert.AreEqual(string.Empty , fc.ConstraintName , "FKC"); + Assert.AreEqual(string.Empty , fc.ConstraintName , "FKC12"); fc.ConstraintName = "myConstraint"; // set/get - Assert.AreEqual("myConstraint" , fc.ConstraintName , "FKC"); + Assert.AreEqual("myConstraint" , fc.ConstraintName , "FKC13"); } [Test] public void ctor_ParentColChildCol() @@ -195,13 +195,13 @@ namespace MonoTests_System.Data try { fc = new ForeignKeyConstraint(new DataColumn[] {dtParent.Columns[0]} ,new DataColumn[] {dtChild.Columns[0],dtChild.Columns[1]}); - Assert.Fail("DS333: ctor Indexer Failed to throw ArgumentException"); + Assert.Fail("FKS14: ctor Indexer Failed to throw ArgumentException"); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Assert.Fail("DS334: ctor. Wrong exception type. Got:" + exc); + Assert.Fail("FKS15: ctor. Wrong exception type. Got:" + exc); } fc = new ForeignKeyConstraint(new DataColumn[] {dtParent.Columns[0],dtParent.Columns[1]} ,new DataColumn[] {dtChild.Columns[0],dtChild.Columns[2]}); @@ -210,78 +210,78 @@ namespace MonoTests_System.Data try { dtChild.Constraints.Add(fc); - Assert.Fail("DS333: ctor Indexer Failed to throw ArgumentException"); + Assert.Fail("FKS16: ctor Indexer Failed to throw ArgumentException"); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Assert.Fail("DS334: ctor. Wrong exception type. Got:" + exc); + Assert.Fail("FKC17: ctor. Wrong exception type. Got:" + exc); } // Child Table Constraints Count - two columnns - Assert.AreEqual(0, dtChild.Constraints.Count , "FKC"); + Assert.AreEqual(0, dtChild.Constraints.Count , "FKC18"); // Parent Table Constraints Count - two columnns - Assert.AreEqual(1, dtParent.Constraints.Count , "FKC"); + Assert.AreEqual(1, dtParent.Constraints.Count , "FKC19"); // DataSet relations Count - Assert.AreEqual(0, ds.Relations.Count , "FKC"); + Assert.AreEqual(0, ds.Relations.Count , "FKC20"); dtParent.Constraints.Clear(); dtChild.Constraints.Clear(); fc = new ForeignKeyConstraint(new DataColumn[] {dtParent.Columns[0]} ,new DataColumn[] {dtChild.Columns[0]}); // Ctor - Assert.AreEqual(false , fc == null , "FKC"); + Assert.AreEqual(false , fc == null , "FKC21"); // Child Table Constraints Count - Assert.AreEqual(0, dtChild.Constraints.Count , "FKC"); + Assert.AreEqual(0, dtChild.Constraints.Count , "FKC22"); // Parent Table Constraints Count Assert.AreEqual(0, dtParent.Constraints.Count , "FKC"); // DataSet relations Count - Assert.AreEqual(0, ds.Relations.Count , "FKC"); + Assert.AreEqual(0, ds.Relations.Count , "FKC23"); dtChild.Constraints.Add(fc); // Child Table Constraints Count, Add - Assert.AreEqual(1, dtChild.Constraints.Count , "FKC"); + Assert.AreEqual(1, dtChild.Constraints.Count , "FKC24"); // Parent Table Constraints Count, Add - Assert.AreEqual(1, dtParent.Constraints.Count , "FKC"); + Assert.AreEqual(1, dtParent.Constraints.Count , "FKC25"); // DataSet relations Count, Add - Assert.AreEqual(0, ds.Relations.Count , "FKC"); + Assert.AreEqual(0, ds.Relations.Count , "FKC26"); // Parent Table Constraints type - Assert.AreEqual(typeof(UniqueConstraint), dtParent.Constraints[0].GetType() , "FKC"); + Assert.AreEqual(typeof(UniqueConstraint), dtParent.Constraints[0].GetType() , "FKC27"); // Parent Table Constraints type - Assert.AreEqual(typeof(ForeignKeyConstraint), dtChild.Constraints[0].GetType() , "FKC"); + Assert.AreEqual(typeof(ForeignKeyConstraint), dtChild.Constraints[0].GetType() , "FKC28"); // Parent Table Primary key - Assert.AreEqual(0, dtParent.PrimaryKey.Length , "FKC"); + Assert.AreEqual(0, dtParent.PrimaryKey.Length , "FKC29"); dtChild.Constraints.Clear(); dtParent.Constraints.Clear(); ds.Relations.Add(new DataRelation("myRelation",dtParent.Columns[0],dtChild.Columns[0])); // Relation - Child Table Constraints Count - Assert.AreEqual(1, dtChild.Constraints.Count , "FKC"); + Assert.AreEqual(1, dtChild.Constraints.Count , "FKC30"); // Relation - Parent Table Constraints Count - Assert.AreEqual(1, dtParent.Constraints.Count , "FKC"); + Assert.AreEqual(1, dtParent.Constraints.Count , "FKC31"); // Relation - Parent Table Constraints type - Assert.AreEqual(typeof(UniqueConstraint), dtParent.Constraints[0].GetType() , "FKC"); + Assert.AreEqual(typeof(UniqueConstraint), dtParent.Constraints[0].GetType() , "FKC32"); // Relation - Parent Table Constraints type - Assert.AreEqual(typeof(ForeignKeyConstraint), dtChild.Constraints[0].GetType() , "FKC"); + Assert.AreEqual(typeof(ForeignKeyConstraint), dtChild.Constraints[0].GetType() , "FKC33"); // Relation - Parent Table Primary key - Assert.AreEqual(0, dtParent.PrimaryKey.Length , "FKC"); + Assert.AreEqual(0, dtParent.PrimaryKey.Length , "FKC34"); } [Test] public void ctor_NameParentColChildCol() @@ -293,10 +293,10 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint("myForeignKey",dtParent.Columns[0],dtChild.Columns[0]); // Ctor - Assert.AreEqual(false , fc == null , "FKC"); + Assert.AreEqual(false , fc == null , "FKC35"); // Ctor - name - Assert.AreEqual("myForeignKey" , fc.ConstraintName , "FKC"); + Assert.AreEqual("myForeignKey" , fc.ConstraintName , "FKC36"); } [Test] public void ctor_NameParentColsChildCols() @@ -308,10 +308,10 @@ namespace MonoTests_System.Data fc = new ForeignKeyConstraint("myForeignKey",new DataColumn[] {dtParent.Columns[0]} ,new DataColumn[] {dtChild.Columns[0]}); // Ctor - Assert.AreEqual(false , fc == null , "FKC"); + Assert.AreEqual(false , fc == null , "FKC37"); // Ctor - name - Assert.AreEqual("myForeignKey" , fc.ConstraintName , "FKC"); + Assert.AreEqual("myForeignKey" , fc.ConstraintName , "FKC38"); } [Test] public void deleteRule() @@ -329,14 +329,14 @@ namespace MonoTests_System.Data //checking default // Default - Assert.AreEqual(Rule.Cascade , fc.DeleteRule , "FKC"); + Assert.AreEqual(Rule.Cascade , fc.DeleteRule , "FKC39"); //checking set/get foreach (Rule rule in Enum.GetValues(typeof(Rule))) { // Set/Get - rule fc.DeleteRule = rule; - Assert.AreEqual(rule, fc.DeleteRule , "FKC"); + Assert.AreEqual(rule, fc.DeleteRule , "FKC40"); } dtChild.Constraints.Add(fc); @@ -349,13 +349,13 @@ namespace MonoTests_System.Data try { dtParent.Rows.Find(1).Delete(); - Assert.Fail("DS333: Find Indexer Failed to throw InvalidConstraintException"); + Assert.Fail("FKC41: Find Indexer Failed to throw InvalidConstraintException"); } catch (InvalidConstraintException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Assert.Fail("DS334: Find. Wrong exception type. Got:" + exc); + Assert.Fail("FKC42: Find. Wrong exception type. Got:" + exc); } // Rule = None, Delete succeed @@ -363,12 +363,12 @@ namespace MonoTests_System.Data foreach (DataRow dr in dtChild.Select("ParentId = 1")) dr.Delete(); dtParent.Rows.Find(1).Delete(); - Assert.AreEqual(0, dtParent.Select("ParentId=1").Length , "FKC"); + Assert.AreEqual(0, dtParent.Select("ParentId=1").Length , "FKC43"); // Rule = Cascade fc.DeleteRule = Rule.Cascade; dtParent.Rows.Find(2).Delete(); - Assert.AreEqual(0, dtChild.Select("ParentId=2").Length , "FKC"); + Assert.AreEqual(0, dtChild.Select("ParentId=2").Length , "FKC44"); // Rule = SetNull DataSet ds1 = new DataSet(); @@ -379,7 +379,7 @@ namespace MonoTests_System.Data fc1.DeleteRule = Rule.SetNull; ds1.Tables[1].Constraints.Add(fc1); - Assert.AreEqual(0, ds1.Tables[1].Select("ChildId is null").Length, "FKC"); + Assert.AreEqual(0, ds1.Tables[1].Select("ChildId is null").Length, "FKC45"); ds1.Tables[0].PrimaryKey= new DataColumn[] {ds1.Tables[0].Columns[0]}; ds1.Tables[0].Rows.Find(3).Delete(); @@ -394,7 +394,7 @@ namespace MonoTests_System.Data Assert.AreEqual(null, dr["ChildId"], "FKC"); }*/ - Assert.AreEqual(4, arr.Length , "FKC"); + Assert.AreEqual(4, arr.Length , "FKC46"); // Rule = SetDefault //fc.DeleteRule = Rule.SetDefault; @@ -414,7 +414,7 @@ namespace MonoTests_System.Data ds1.Tables[0].PrimaryKey= new DataColumn[] {ds1.Tables[0].Columns[0]}; ds1.Tables[0].Rows.Find(3).Delete(); - Assert.AreEqual(4, ds1.Tables[1].Select("ChildId=777").Length , "FKC"); + Assert.AreEqual(4, ds1.Tables[1].Select("ChildId=777").Length , "FKC47"); } [Test] public void extendedProperties() @@ -428,10 +428,187 @@ namespace MonoTests_System.Data PropertyCollection pc = fc.ExtendedProperties ; // Checking ExtendedProperties default - Assert.AreEqual(true, fc != null, "FKC"); + Assert.AreEqual(true, fc != null, "FKC48"); // Checking ExtendedProperties count - Assert.AreEqual(0, pc.Count , "FKC"); + Assert.AreEqual(0, pc.Count , "FKC49"); + } + + [Test]
+ public void ctor_DclmDclm()
+ {
+ DataTable dtParent = DataProvider.CreateParentDataTable();
+ DataTable dtChild = DataProvider.CreateChildDataTable();
+ DataSet ds = new DataSet();
+ ds.Tables.Add(dtChild);
+ ds.Tables.Add(dtParent);
+
+ ForeignKeyConstraint fc = null;
+ fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]);
+
+ Assert.IsFalse(fc == null ,"FKC64" );
+
+ Assert.AreEqual(0,dtChild.Constraints.Count ,"FKC50");
+
+ Assert.AreEqual(0,dtParent.Constraints.Count ,"FKC51");
+
+ Assert.AreEqual(0,ds.Relations.Count ,"FKC52");
+
+ dtChild.Constraints.Add(fc);
+
+ Assert.AreEqual(1,dtChild.Constraints.Count ,"FKC53");
+
+ Assert.AreEqual(1,dtParent.Constraints.Count ,"FKC54");
+
+ Assert.AreEqual(0,ds.Relations.Count ,"FKC55");
+
+ Assert.AreEqual(typeof(UniqueConstraint),dtParent.Constraints[0].GetType() ,"FKC56");
+
+ Assert.AreEqual(typeof(ForeignKeyConstraint),dtChild.Constraints[0].GetType() ,"FKC57");
+
+ Assert.AreEqual(0,dtParent.PrimaryKey.Length ,"FKC58");
+
+ dtChild.Constraints.Clear();
+ dtParent.Constraints.Clear();
+ ds.Relations.Add(new DataRelation("myRelation",dtParent.Columns[0],dtChild.Columns[0]));
+
+ Assert.AreEqual(1,dtChild.Constraints.Count ,"FKC59");
+
+ Assert.AreEqual(1,dtParent.Constraints.Count ,"FKC60");
+
+ Assert.AreEqual(typeof(UniqueConstraint),dtParent.Constraints[0].GetType() ,"FKC61");
+
+ Assert.AreEqual(typeof(ForeignKeyConstraint),dtChild.Constraints[0].GetType() ,"FKC62");
+
+ Assert.AreEqual(0,dtParent.PrimaryKey.Length ,"FKC63");
+ }
+
+ [Test]
+ [ExpectedException(typeof(NullReferenceException))]
+ public void ctor_DclmDclm1()
+ {
+ ForeignKeyConstraint fc = new ForeignKeyConstraint((DataColumn)null,(DataColumn)null);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void ctor_DclmDclm2()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(DataProvider.CreateParentDataTable());
+ ds.Tables.Add(DataProvider.CreateChildDataTable());
+ ds.Tables["Parent"].Columns["ParentId"].Expression = "2";
+
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void ctor_DclmDclm3()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(DataProvider.CreateParentDataTable());
+ ds.Tables.Add(DataProvider.CreateChildDataTable());
+ ds.Tables["Child"].Columns["ParentId"].Expression = "2";
+
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]); + } + + [Test]
+ public void UpdateRule1()
+ {
+ DataSet ds = GetNewDataSet();
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]);
+ fc.UpdateRule=Rule.Cascade;
+ ds.Tables[1].Constraints.Add(fc);
+
+ //Changing parent row
+
+ ds.Tables[0].Rows.Find(1)["ParentId"] = 8;
+
+ ds.Tables[0].AcceptChanges();
+ ds.Tables[1].AcceptChanges();
+ //Checking the table
+
+ Assert.IsTrue(ds.Tables[1].Select("ParentId=8").Length > 0, "FKC66");
+
+ }
+
+ [Test]
+ [ExpectedException(typeof(ConstraintException))]
+ public void UpdateRule2()
+ {
+ DataSet ds = GetNewDataSet();
+ ds.Tables[0].PrimaryKey=null;
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]);
+ fc.UpdateRule=Rule.None;
+ ds.Tables[1].Constraints.Add(fc);
+
+ //Changing parent row
+
+ ds.Tables[0].Rows[0]["ParentId"] = 5;
+
+ /*ds.Tables[0].AcceptChanges();
+ ds.Tables[1].AcceptChanges();
+ //Checking the table
+ Compare(ds.Tables[1].Select("ParentId=8").Length ,0);*/
+ }
+
+ [Test]
+ public void UpdateRule3()
+ {
+ DataSet ds = GetNewDataSet();
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[1]);
+ fc.UpdateRule=Rule.SetDefault;
+ ds.Tables[1].Constraints.Add(fc);
+
+ //Changing parent row
+
+ ds.Tables[1].Columns[1].DefaultValue="777";
+
+ //Add new row --> in order to apply the forigen key rules
+ DataRow dr = ds.Tables[0].NewRow();
+ dr["ParentId"] = 777;
+ ds.Tables[0].Rows.Add(dr);
+
+
+ ds.Tables[0].Rows.Find(1)["ParentId"] = 8;
+
+ ds.Tables[0].AcceptChanges();
+ ds.Tables[1].AcceptChanges();
+ //Checking the table
+
+ Assert.IsTrue(ds.Tables[1].Select("ChildId=777").Length > 0, "FKC67");
+ }
+
+ [Test]
+ public void UpdateRule4()
+ {
+ DataSet ds = GetNewDataSet();
+ ForeignKeyConstraint fc = new ForeignKeyConstraint(ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]);
+ fc.UpdateRule=Rule.SetNull;
+ ds.Tables[1].Constraints.Add(fc);
+
+ //Changing parent row
+
+ ds.Tables[0].Rows.Find(1)["ParentId"] = 8;
+
+ ds.Tables[0].AcceptChanges();
+ ds.Tables[1].AcceptChanges();
+ //Checking the table
+
+ Assert.IsTrue(ds.Tables[1].Select("ParentId is null").Length > 0, "FKC68");
+
+ }
+
+ private DataSet GetNewDataSet()
+ {
+ DataSet ds1 = new DataSet();
+ ds1.Tables.Add(DataProvider.CreateParentDataTable());
+ ds1.Tables.Add(DataProvider.CreateChildDataTable());
+ ds1.Tables[0].PrimaryKey= new DataColumn[] {ds1.Tables[0].Columns[0]};
+
+ return ds1;
} } } diff --git a/mcs/class/System.Data/Test/System.Data/MissingPrimaryKeyExceptionTest.cs b/mcs/class/System.Data/Test/System.Data/MissingPrimaryKeyExceptionTest.cs new file mode 100644 index 00000000000..0393b93befc --- /dev/null +++ b/mcs/class/System.Data/Test/System.Data/MissingPrimaryKeyExceptionTest.cs @@ -0,0 +1,60 @@ +// 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 NUnit.Framework;
+using MonoTests.System.Data.Utils;
+
+namespace MonoTests_System.Data +{
+ [TestFixture]
+ class MissingPrimaryKeyExceptionTest
+ {
+ [Test]
+ [ExpectedException(typeof(MissingPrimaryKeyException))]
+ public void Generate1()
+ {
+ DataTable tbl = DataProvider.CreateParentDataTable();
+ //can't invoke Find method with no primary key
+
+ tbl.Rows.Find("Something");
+ }
+
+ [Test]
+ [ExpectedException(typeof(MissingPrimaryKeyException))]
+ public void Generate2()
+ {
+ DataTable tbl = DataProvider.CreateParentDataTable();
+ //can't invoke Contains method with no primary key
+
+ tbl.Rows.Contains("Something");
+ }
+ }
+}
\ No newline at end of file diff --git a/mcs/class/System.Data/Test/System.Data/TypedDataSet.xml b/mcs/class/System.Data/Test/System.Data/TypedDataSet.xml new file mode 100644 index 00000000000..3ef559f4f70 --- /dev/null +++ b/mcs/class/System.Data/Test/System.Data/TypedDataSet.xml @@ -0,0 +1,563 @@ +<?xml version="1.0" standalone="yes"?>
+<myTypedDataSet xmlns="http://www.tempuri.org/myTypedDataSet.xsd">
+ <Order_x0020_Details>
+ <OrderID>10250</OrderID>
+ <ProductID>41</ProductID>
+ <UnitPrice>7.7000</UnitPrice>
+ <Quantity>10</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10250</OrderID>
+ <ProductID>51</ProductID>
+ <UnitPrice>42.4000</UnitPrice>
+ <Quantity>35</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10250</OrderID>
+ <ProductID>65</ProductID>
+ <UnitPrice>16.8000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10251</OrderID>
+ <ProductID>22</ProductID>
+ <UnitPrice>16.8000</UnitPrice>
+ <Quantity>6</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10251</OrderID>
+ <ProductID>57</ProductID>
+ <UnitPrice>15.6000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10251</OrderID>
+ <ProductID>65</ProductID>
+ <UnitPrice>16.8000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10252</OrderID>
+ <ProductID>20</ProductID>
+ <UnitPrice>64.8000</UnitPrice>
+ <Quantity>40</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10252</OrderID>
+ <ProductID>33</ProductID>
+ <UnitPrice>2.0000</UnitPrice>
+ <Quantity>25</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10252</OrderID>
+ <ProductID>60</ProductID>
+ <UnitPrice>27.2000</UnitPrice>
+ <Quantity>40</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10253</OrderID>
+ <ProductID>31</ProductID>
+ <UnitPrice>10.0000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10253</OrderID>
+ <ProductID>39</ProductID>
+ <UnitPrice>14.4000</UnitPrice>
+ <Quantity>42</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10253</OrderID>
+ <ProductID>49</ProductID>
+ <UnitPrice>16.0000</UnitPrice>
+ <Quantity>40</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10254</OrderID>
+ <ProductID>24</ProductID>
+ <UnitPrice>3.6000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10254</OrderID>
+ <ProductID>55</ProductID>
+ <UnitPrice>19.2000</UnitPrice>
+ <Quantity>21</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10254</OrderID>
+ <ProductID>74</ProductID>
+ <UnitPrice>8.0000</UnitPrice>
+ <Quantity>21</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10255</OrderID>
+ <ProductID>2</ProductID>
+ <UnitPrice>15.2000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10255</OrderID>
+ <ProductID>16</ProductID>
+ <UnitPrice>13.9000</UnitPrice>
+ <Quantity>35</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10255</OrderID>
+ <ProductID>36</ProductID>
+ <UnitPrice>15.2000</UnitPrice>
+ <Quantity>25</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10255</OrderID>
+ <ProductID>59</ProductID>
+ <UnitPrice>44.0000</UnitPrice>
+ <Quantity>30</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10256</OrderID>
+ <ProductID>53</ProductID>
+ <UnitPrice>26.2000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10256</OrderID>
+ <ProductID>77</ProductID>
+ <UnitPrice>10.4000</UnitPrice>
+ <Quantity>12</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10257</OrderID>
+ <ProductID>27</ProductID>
+ <UnitPrice>35.1000</UnitPrice>
+ <Quantity>25</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10257</OrderID>
+ <ProductID>39</ProductID>
+ <UnitPrice>14.4000</UnitPrice>
+ <Quantity>6</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10257</OrderID>
+ <ProductID>77</ProductID>
+ <UnitPrice>10.4000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10258</OrderID>
+ <ProductID>2</ProductID>
+ <UnitPrice>15.2000</UnitPrice>
+ <Quantity>50</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10258</OrderID>
+ <ProductID>5</ProductID>
+ <UnitPrice>17.0000</UnitPrice>
+ <Quantity>65</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10258</OrderID>
+ <ProductID>32</ProductID>
+ <UnitPrice>25.6000</UnitPrice>
+ <Quantity>6</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10259</OrderID>
+ <ProductID>21</ProductID>
+ <UnitPrice>8.0000</UnitPrice>
+ <Quantity>10</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10259</OrderID>
+ <ProductID>37</ProductID>
+ <UnitPrice>20.8000</UnitPrice>
+ <Quantity>1</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10260</OrderID>
+ <ProductID>41</ProductID>
+ <UnitPrice>7.7000</UnitPrice>
+ <Quantity>16</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10260</OrderID>
+ <ProductID>57</ProductID>
+ <UnitPrice>15.6000</UnitPrice>
+ <Quantity>50</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10260</OrderID>
+ <ProductID>62</ProductID>
+ <UnitPrice>39.4000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10260</OrderID>
+ <ProductID>70</ProductID>
+ <UnitPrice>12.0000</UnitPrice>
+ <Quantity>21</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10261</OrderID>
+ <ProductID>21</ProductID>
+ <UnitPrice>8.0000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10261</OrderID>
+ <ProductID>35</ProductID>
+ <UnitPrice>14.4000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10262</OrderID>
+ <ProductID>5</ProductID>
+ <UnitPrice>17.0000</UnitPrice>
+ <Quantity>12</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10262</OrderID>
+ <ProductID>7</ProductID>
+ <UnitPrice>24.0000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10262</OrderID>
+ <ProductID>56</ProductID>
+ <UnitPrice>30.4000</UnitPrice>
+ <Quantity>2</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10263</OrderID>
+ <ProductID>16</ProductID>
+ <UnitPrice>13.9000</UnitPrice>
+ <Quantity>60</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10263</OrderID>
+ <ProductID>24</ProductID>
+ <UnitPrice>3.6000</UnitPrice>
+ <Quantity>28</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10263</OrderID>
+ <ProductID>30</ProductID>
+ <UnitPrice>20.7000</UnitPrice>
+ <Quantity>60</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10263</OrderID>
+ <ProductID>74</ProductID>
+ <UnitPrice>8.0000</UnitPrice>
+ <Quantity>36</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10264</OrderID>
+ <ProductID>2</ProductID>
+ <UnitPrice>15.2000</UnitPrice>
+ <Quantity>35</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10264</OrderID>
+ <ProductID>41</ProductID>
+ <UnitPrice>7.7000</UnitPrice>
+ <Quantity>25</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10265</OrderID>
+ <ProductID>17</ProductID>
+ <UnitPrice>31.2000</UnitPrice>
+ <Quantity>30</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10265</OrderID>
+ <ProductID>70</ProductID>
+ <UnitPrice>12.0000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10266</OrderID>
+ <ProductID>12</ProductID>
+ <UnitPrice>30.4000</UnitPrice>
+ <Quantity>12</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10267</OrderID>
+ <ProductID>40</ProductID>
+ <UnitPrice>14.7000</UnitPrice>
+ <Quantity>50</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10267</OrderID>
+ <ProductID>59</ProductID>
+ <UnitPrice>44.0000</UnitPrice>
+ <Quantity>70</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10267</OrderID>
+ <ProductID>76</ProductID>
+ <UnitPrice>14.4000</UnitPrice>
+ <Quantity>15</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10268</OrderID>
+ <ProductID>29</ProductID>
+ <UnitPrice>99.0000</UnitPrice>
+ <Quantity>10</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10268</OrderID>
+ <ProductID>72</ProductID>
+ <UnitPrice>27.8000</UnitPrice>
+ <Quantity>4</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10269</OrderID>
+ <ProductID>33</ProductID>
+ <UnitPrice>2.0000</UnitPrice>
+ <Quantity>60</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10269</OrderID>
+ <ProductID>72</ProductID>
+ <UnitPrice>27.8000</UnitPrice>
+ <Quantity>20</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10270</OrderID>
+ <ProductID>36</ProductID>
+ <UnitPrice>15.2000</UnitPrice>
+ <Quantity>30</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Order_x0020_Details>
+ <OrderID>10270</OrderID>
+ <ProductID>43</ProductID>
+ <UnitPrice>36.8000</UnitPrice>
+ <Quantity>25</Quantity>
+ <Discount>5.0</Discount>
+ </Order_x0020_Details>
+ <Orders>
+ <OrderID>10250</OrderID>
+ <CustomerID>HANAR</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-08T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-05T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-12T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10251</OrderID>
+ <CustomerID>VICTE</CustomerID>
+ <EmployeeID>3</EmployeeID>
+ <OrderDate>1996-07-08T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-05T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-15T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10252</OrderID>
+ <CustomerID>SUPRD</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-09T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-06T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-11T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10253</OrderID>
+ <CustomerID>HANAR</CustomerID>
+ <EmployeeID>3</EmployeeID>
+ <OrderDate>1996-07-10T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-07-24T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-16T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10254</OrderID>
+ <CustomerID>CHOPS</CustomerID>
+ <EmployeeID>5</EmployeeID>
+ <OrderDate>1996-07-11T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-08T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-23T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10255</OrderID>
+ <CustomerID>RICSU</CustomerID>
+ <EmployeeID>9</EmployeeID>
+ <OrderDate>1996-07-12T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-09T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-15T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10256</OrderID>
+ <CustomerID>WELLI</CustomerID>
+ <EmployeeID>3</EmployeeID>
+ <OrderDate>1996-07-15T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-12T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-17T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10257</OrderID>
+ <CustomerID>HILAA</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-16T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-13T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-22T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10258</OrderID>
+ <CustomerID>ERNSH</CustomerID>
+ <EmployeeID>1</EmployeeID>
+ <OrderDate>1996-07-17T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-14T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-23T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10259</OrderID>
+ <CustomerID>CENTC</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-18T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-15T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-25T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10260</OrderID>
+ <CustomerID>OTTIK</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-19T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-16T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-29T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10261</OrderID>
+ <CustomerID>QUEDE</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-19T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-16T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-30T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10262</OrderID>
+ <CustomerID>RATTC</CustomerID>
+ <EmployeeID>8</EmployeeID>
+ <OrderDate>1996-07-22T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-19T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-25T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10263</OrderID>
+ <CustomerID>ERNSH</CustomerID>
+ <EmployeeID>9</EmployeeID>
+ <OrderDate>1996-07-23T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-20T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-31T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10264</OrderID>
+ <CustomerID>FOLKO</CustomerID>
+ <EmployeeID>6</EmployeeID>
+ <OrderDate>1996-07-24T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-21T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-23T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10265</OrderID>
+ <CustomerID>BLONP</CustomerID>
+ <EmployeeID>2</EmployeeID>
+ <OrderDate>1996-07-25T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-22T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-12T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10266</OrderID>
+ <CustomerID>WARTH</CustomerID>
+ <EmployeeID>3</EmployeeID>
+ <OrderDate>1996-07-26T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-09-06T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-07-31T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10267</OrderID>
+ <CustomerID>FRANK</CustomerID>
+ <EmployeeID>4</EmployeeID>
+ <OrderDate>1996-07-29T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-26T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-06T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10268</OrderID>
+ <CustomerID>GROSR</CustomerID>
+ <EmployeeID>8</EmployeeID>
+ <OrderDate>1996-07-30T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-27T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-02T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10269</OrderID>
+ <CustomerID>WHITC</CustomerID>
+ <EmployeeID>5</EmployeeID>
+ <OrderDate>1996-07-31T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-14T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-09T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+ <Orders>
+ <OrderID>10270</OrderID>
+ <CustomerID>WARTH</CustomerID>
+ <EmployeeID>1</EmployeeID>
+ <OrderDate>1996-08-01T00:00:00.0000000+03:00</OrderDate>
+ <RequiredDate>1996-08-29T00:00:00.0000000+03:00</RequiredDate>
+ <ShippedDate>1996-08-02T00:00:00.0000000+03:00</ShippedDate>
+ </Orders>
+</myTypedDataSet>
\ No newline at end of file diff --git a/mcs/class/System.Data/Test/System.Data/VersionNotFoundException.cs b/mcs/class/System.Data/Test/System.Data/VersionNotFoundException.cs new file mode 100644 index 00000000000..3d4fb4562c6 --- /dev/null +++ b/mcs/class/System.Data/Test/System.Data/VersionNotFoundException.cs @@ -0,0 +1,76 @@ +// 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 NUnit.Framework;
+using MonoTests.System.Data.Utils;
+
+namespace MonoTests_System.Data +{
+ [TestFixture]
+ class VersionNotFoundExceptionTest
+ {
+ [Test]
+ [ExpectedException(typeof(VersionNotFoundException))]
+ public void Generate1()
+ {
+ DataTable tbl = DataProvider.CreateChildDataTable();
+ DataRow drParent = tbl.Rows[0];
+ drParent.Delete();
+ tbl.AcceptChanges();
+
+ object obj = drParent[0,DataRowVersion.Proposed];
+ }
+
+ [Test]
+ [ExpectedException(typeof(VersionNotFoundException))]
+ public void Generate2()
+ {
+ DataTable tbl = DataProvider.CreateChildDataTable();
+ DataRow drParent = tbl.Rows[0];
+ drParent.Delete();
+ tbl.AcceptChanges();
+
+ object obj = drParent[0,DataRowVersion.Current];
+ }
+
+ [Test]
+ [ExpectedException(typeof(VersionNotFoundException))]
+ public void Generate3()
+ {
+ DataTable tbl = DataProvider.CreateChildDataTable();
+ DataRow drParent = tbl.Rows[0];
+ drParent.Delete();
+ tbl.AcceptChanges();
+
+ object obj = drParent[0,DataRowVersion.Original];
+ }
+ }
+}
\ No newline at end of file |