+2005-07-12 Eyal Alalouf <eyala@mainsoft.com>
+ * System.Data_tests.dll.sources:
+ Standardized Mainsoft System.Data exception tests
+
2005-07-12 Eyal Alalouf <eyala@mainsoft.com>
* System.Data_tests.dll.sources:
Unified Mainsoft DataRelation tests into one test in Test/System.Data
System.Data/DataRelationCollectionTest2.cs
System.Data/DataTableCollectionTest.cs
System.Data/DataTableCollectionTest2.cs
+System.Data/DeletedRowInaccessibleExceptionTest.cs
+System.Data/DuplicateNameExceptionTest.cs
+System.Data/ConstraintExceptionTest.cs
+System.Data/EvaluateExceptionTest.cs
+System.Data/InRowChangingEventExceptionTest.cs
+System.Data/InvalidConstraintExceptionTest.cs
+System.Data/NoNullAllowedExceptionTest.cs
+System.Data/ReadOnlyExceptionTest.cs
+System.Data/SyntaxErrorExceptionTest.cs
+System.Data/RowNotInTableExceptionTest.cs
System.Data.Common/DbProviderFactoriesConfigurationHandlerTest.cs
System.Data.Common/ConnectionStringsSectionTest.cs
System.Data.Common/DataColumnMappingCollectionTest.cs
System.Data.Tests.Mainsoft/GHTUtils/HttpClientBase.cs
System.Data.Tests.Mainsoft/GHTUtils/ObjectTester.cs
System.Data.Tests.Mainsoft/GHTUtils/XmlUtils.cs
-System.Data.Tests.Mainsoft/System.Data/ConstraintException/ConstraintException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/DeletedRowInaccessibleException/DeletedRowInaccessibleException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/DuplicateNameException/DuplicateNameException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/EvaluateException/EvaluateException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/InRowChangingEventException/InRowChangingEventException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/InvalidConstraintException/InvalidConstraintException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/NoNullAllowedException/NoNullAllowedException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/ReadOnlyException/ReadOnlyException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/RowNotInTableException/RowNotInTableException_Generate.cs
-System.Data.Tests.Mainsoft/System.Data/SyntaxErrorException/SyntaxErrorException_Generate.cs
+2005-07-12 Eyal Alalouf <eyala@mainsoft.com>
+
+ * DeletedRowInaccessibleExceptionTest: Added file
+ * DuplicateNameExceptionTest: Added file
+ * ConstraintExceptionTest: Added file
+ * EvaluateExceptionTest: Added file
+ * InRowChangingEventExceptionTest: Added file
+ * InvalidConstraintExceptionTest: Added file
+ * NoNullAllowedExceptionTest: Added file
+ * ReadOnlyExceptionTest: Added file
+ * SyntaxErrorExceptionTest: Added file
+ * RowNotInTableExceptionTest: Added file
+
2005-07-12 Eyal Alalouf <eyala@mainsoft.com>
* DataRelationTest2.cs: Added file
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class ConstraintExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ DataTable dtParent= GHTUtils.DataProvider.CreateParentDataTable();
+ DataTable dtChild = GHTUtils.DataProvider.CreateChildDataTable();
+
+ DataSet ds = new DataSet();
+ ds.Tables.Add(dtChild);
+ ds.Tables.Add(dtParent);
+
+ //------ check UniqueConstraint ---------
+
+ //create unique constraint
+ UniqueConstraint uc;
+
+ //Column type = int
+ uc = new UniqueConstraint(dtParent.Columns[0]);
+ dtParent.Constraints.Add(uc);
+ // UniqueConstraint Exception - Column type = int
+ try
+ {
+ //add exisiting value - will raise exception
+ dtParent.Rows.Add(dtParent.Rows[0].ItemArray);
+ Assert.Fail("CNE1: Rows.Add failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE2: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //Column type = DateTime
+ dtParent.Constraints.Clear();
+ uc = new UniqueConstraint(dtParent.Columns["ParentDateTime"]);
+ dtParent.Constraints.Add(uc);
+ // UniqueConstraint Exception - Column type = DateTime
+ try
+ {
+ //add exisiting value - will raise exception
+ dtParent.Rows.Add(dtParent.Rows[0].ItemArray);
+ Assert.Fail("CNE3: Rows.Add failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE4: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //Column type = double
+ dtParent.Constraints.Clear();
+ uc = new UniqueConstraint(dtParent.Columns["ParentDouble"]);
+ dtParent.Constraints.Add(uc);
+ // UniqueConstraint Exception - Column type = double
+ try
+ {
+ //add exisiting value - will raise exception
+ dtParent.Rows.Add(dtParent.Rows[0].ItemArray);
+ Assert.Fail("CNE5: Rows.Add failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE6: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //Column type = string
+ dtParent.Constraints.Clear();
+ uc = new UniqueConstraint(dtParent.Columns["String1"]);
+ dtParent.Constraints.Add(uc);
+ // UniqueConstraint Exception - Column type = String
+ try
+ {
+ //add exisiting value - will raise exception
+ dtParent.Rows.Add(dtParent.Rows[0].ItemArray);
+ Assert.Fail("CNE7: Rows.Add failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE8: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //Column type = string, ds.CaseSensitive = false;
+ ds.CaseSensitive = false;
+
+ dtParent.Constraints.Clear();
+ uc = new UniqueConstraint(dtParent.Columns["String1"]);
+ dtParent.Constraints.Add(uc);
+ DataRow dr = dtParent.NewRow();
+ dr.ItemArray = dtParent.Rows[0].ItemArray ;
+ dr["String1"] = dr["String1"].ToString().ToUpper();
+
+ // UniqueConstraint Exception - Column type = String, CaseSensitive = false;
+ try
+ {
+ dtParent.Rows.Add(dr);
+ Assert.Fail("CNE9: Rows.Add failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE10: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //Column type = string, ds.CaseSensitive = true;
+ ds.CaseSensitive = true;
+
+ dtParent.Constraints.Clear();
+ uc = new UniqueConstraint(dtParent.Columns["String1"]);
+ dtParent.Constraints.Add(uc);
+
+ // No UniqueConstraint Exception - Column type = String, CaseSensitive = true;
+ dtParent.Rows.Add(dr);
+
+ // Column type = string, ds.CaseSensitive = false;
+ // UniqueConstraint Exception - Column type = String, Enable CaseSensitive = true;
+ try
+ {
+ ds.CaseSensitive = false;
+ Assert.Fail("CNE13: CaseSensitive failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE14: CaseSensitive wrong exception type. Got: " + exc);
+ }
+
+ dtChild.Constraints.Add(new UniqueConstraint(new DataColumn[] {dtChild.Columns[0],dtChild.Columns[1]}));
+ ds.EnforceConstraints = false;
+ dtChild.Rows.Add(dtChild.Rows[0].ItemArray);
+
+ // UniqueConstraint Exception - ds.EnforceConstraints
+ try
+ {
+ ds.EnforceConstraints = true;
+ Assert.Fail("CNE15: EnforceConstraints failed to raise ConstraintException.");
+ }
+ catch (ConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("CNE16: EnforceConstraints wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class DeletedRowInaccessibleExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ DataTable dtParent;
+ dtParent= DataProvider.CreateParentDataTable();
+
+ DataRow dr = dtParent.Rows[0];
+ dr.Delete();
+
+ // DeletedRowInaccessible Exception (BeginEdit)
+ try
+ {
+ dr.BeginEdit();
+ Assert.Fail("DRIE1: BeginEdit failed to raise DeletedRowInaccessibleException.");
+ }
+ catch (DeletedRowInaccessibleException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DRIE2: Indexer wrong exception type. Got: " + exc);
+ }
+
+ // DeletedRowInaccessible Exception (Item)
+ try
+ {
+ string s = dr[0].ToString();
+ Assert.Fail("DRIE3: Indexer failed to raise DeletedRowInaccessibleException.");
+ }
+ catch (DeletedRowInaccessibleException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DRIE4: Indexer wrong exception type. Got: " + exc);
+ }
+
+ // DeletedRowInaccessible Exception (ItemArray)
+ try
+ {
+ object[] o = dr.ItemArray;
+ Assert.Fail("DRIE5: Indexer failed to raise DeletedRowInaccessibleException.");
+ }
+ catch (DeletedRowInaccessibleException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DRIE6: Indexer wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class DuplicateNameExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(new DataTable("Table"));
+ ds.Tables.Add(new DataTable("Table1"));
+ ds.Tables[0].Columns.Add(new DataColumn("Column"));
+ ds.Tables[0].Columns.Add(new DataColumn("Column1"));
+ ds.Tables[0].Columns.Add(new DataColumn("Column2"));
+ ds.Tables[1].Columns.Add(new DataColumn("Column"));
+
+ ds.Relations.Add(new DataRelation("Relation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
+ ds.Tables[0].Constraints.Add(new UniqueConstraint("Constraint",ds.Tables[0].Columns[1]));
+
+ // DuplicateNameException - tables
+ try
+ {
+ ds.Tables.Add(new DataTable("Table"));
+ Assert.Fail("DNE1: Tables.Add failed to raise DuplicateNameException.");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DNE2: Tables.Add wrong exception type. Got: " + exc);
+ }
+
+ // DuplicateNameException - Column
+ try
+ {
+ ds.Tables[0].Columns.Add(new DataColumn("Column"));
+ Assert.Fail("DNE3: Tables[0].Columns.Add failed to raise DuplicateNameException.");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DNE4: Tables[0].Columns.Add wrong exception type. Got: " + exc);
+ }
+
+ // DuplicateNameException - Constraints
+ try
+ {
+ ds.Tables[0].Constraints.Add(new UniqueConstraint("Constraint",ds.Tables[0].Columns[2]));
+ Assert.Fail("DNE5: Tables[0].Constraints.Add failed to raise DuplicateNameException.");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DNE6: Tables[0].Constraints.Add wrong exception type. Got: " + exc);
+ }
+
+ // DuplicateNameException - Relations
+ try
+ {
+ ds.Relations.Add(new DataRelation("Relation",ds.Tables[0].Columns[1],ds.Tables[1].Columns[0]));
+ Assert.Fail("DNE7: Relations.Add failed to raise DuplicateNameException.");
+ }
+ catch (DuplicateNameException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("DNE8: Relations.Add wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+//using GHTUtils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class EvaluateExceptionTest
+ {
+ [Test]
+ [Category("NotWorking")]
+ public void Generate()
+ {
+ Exception tmpEx = new Exception() ;
+
+ DataTable tbl = new DataTable();
+ tbl.Columns.Add(new DataColumn("Column"));
+ DataColumn dc = new DataColumn();
+ dc.Expression = "something"; //invalid expression
+
+ // EvaluateException - Column
+ try
+ {
+ tbl.Columns.Add(dc);
+ Assert.Fail("EVE1: Columns.Add failed to raise EvaluateException.");
+ }
+ catch (EvaluateException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("EVE2: Columns.Add wrong exception type. Got: " + exc);
+ }
+
+ // EvaluateException - Column Expression
+ try
+ {
+ tbl.Columns[0].Expression = "Min(AK47)"; //invalid expression
+ Assert.Fail("EVE3: Columns[0].Expression failed to raise EvaluateException.");
+ }
+ catch (EvaluateException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("EVE4: Columns[0].Expression wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class InRowChangingEventExceptionTest
+ {
+ private bool _EventTriggered = false;
+ [Test] public void Generate()
+ {
+ DataTable dt = DataProvider.CreateParentDataTable();
+
+ dt.RowChanging += new DataRowChangeEventHandler ( Row_Changing );
+ dt.Rows[0][1] = "NewValue";
+
+ //this event must be raised in order to test the exception
+ // RowChanging - Event raised
+ Assert.AreEqual(true , _EventTriggered , "IRCEE1");
+ }
+
+ private void Row_Changing( object sender, DataRowChangeEventArgs e )
+ {
+ // InRowChangingEventException - EndEdit
+ try
+ {
+ e.Row.EndEdit(); //can't invoke EndEdit while in ChangingEvent
+ Assert.Fail("IRCEE2: Row.EndEdit failed to raise InRowChangingEventException.");
+ }
+ catch (InRowChangingEventException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("IRCEE3: Columns.Add wrong exception type. Got: " + exc);
+ }
+ _EventTriggered = true;
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class InvalidConstraintExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ DataTable dtParent;
+ dtParent= DataProvider.CreateParentDataTable();
+ Exception tmpEx = new Exception();
+
+ //------ check ForeignKeyConstraint ---------
+ DataTable dtChild = DataProvider.CreateChildDataTable();
+ DataSet ds = new DataSet();
+ ds.Tables.Add(dtChild);
+ ds.Tables.Add(dtParent);
+
+ ds.Relations.Add(new DataRelation("myRelation",dtParent.Columns[0],dtChild.Columns[0],true));
+
+ //update to value which is not exists in Parent table
+ // InvalidConstraintException - update child row
+ try
+ {
+ dtChild.Rows[0]["ParentId"] = 99;
+ Assert.Fail("ICE1: Rows Indexer failed to raise InvalidConstraintException.");
+ }
+ catch (InvalidConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ICE2: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ //Add another relation to the same column of the existing relation in child table
+ // InvalidConstraintException - Add Relation Child
+ try
+ {
+ ds.Relations.Add(new DataRelation("test",dtParent.Columns[2],dtChild.Columns[0],true));
+ Assert.Fail("ICE3: Relations.Add failed to raise InvalidConstraintException.");
+ }
+ catch (InvalidConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ICE4: Relations.Add wrong exception type. Got: " + exc);
+ }
+
+ // ?????????????????? should throw exception - according to MSDN
+ // // InvalidConstraintException -
+ // //ds.Relations.Clear();
+ // try {
+ // dtParent.Rows[0].GetParentRows("myRelation");
+ // Assert.Fail("ICE5: Relations failed to raise InvalidConstraintException.");
+ // }
+ // catch (InvalidConstraintException) {}
+ // catch (AssertionException) { throw; }
+ // catch (Exception exc)
+ // {
+ // Assert.Fail("ICE6: Relations wrong exception type. Got: " + exc);
+ // }
+
+ //Attempt to clear rows from parent table
+ // InvalidConstraintException - RowsCollection.Clear
+ try
+ {
+ dtParent.Rows.Clear();
+ Assert.Fail("ICE7: Rows.Clear failed to raise InvalidConstraintException.");
+ }
+ catch (InvalidConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ICE8: Rows.Clear wrong exception type. Got: " + exc);
+ }
+
+ //try to run commands on two different datasets
+ DataSet ds1 = new DataSet();
+ ds1.Tables.Add(dtParent.Copy());
+
+ // InvalidConstraintException - Add relation with two DataSets
+ try
+ {
+ ds.Relations.Add(new DataRelation("myRelation",ds1.Tables[0].Columns[0],dtChild.Columns[0],true));
+ Assert.Fail("ICE9: Relations.Add failed to raise InvalidConstraintException.");
+ }
+ catch (InvalidConstraintException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ICE10: Relations.Add wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class NoNullAllowedExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ DataTable tbl = DataProvider.CreateParentDataTable();
+
+ // ----------- check with columnn type int -----------------------
+ tbl.Columns[0].AllowDBNull = false;
+
+ //add new row with null value
+ // NoNullAllowedException - Add Row
+ try
+ {
+ tbl.Rows.Add(new object[] {null,"value","value",new DateTime(0),0.5,true});
+ Assert.Fail("NNAE1: Rows.Add failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE2: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //add new row with DBNull value
+ // NoNullAllowedException - Add Row
+ try
+ {
+ tbl.Rows.Add(new object[] {DBNull.Value,"value","value",new DateTime(0),0.5,true});
+ Assert.Fail("NNAE3: Rows.Add failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE4: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - ItemArray
+ try
+ {
+ tbl.Rows[0].ItemArray = new object[] {DBNull.Value,"value","value",new DateTime(0),0.5,true};
+ Assert.Fail("NNAE5: Rows Indexer failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE6: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - Add Row - LoadDataRow
+ try
+ {
+ tbl.LoadDataRow(new object[] {DBNull.Value,"value","value",new DateTime(0),0.5,true},true);
+ Assert.Fail("NNAE7: LoadDataRow failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE8: LoadDataRow wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - EndEdit
+ tbl.Rows[0].BeginEdit();
+ tbl.Rows[0][0] = DBNull.Value ;
+ try
+ {
+ tbl.Rows[0].EndEdit();
+ Assert.Fail("NNAE7: Rows Indexer failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE8: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ // ----------- add new column -----------------------
+ tbl.Columns[0].AllowDBNull = true;
+ tbl.Columns.Add(new DataColumn("bolCol",typeof(bool)));
+
+ // add new column
+ try
+ {
+ tbl.Columns[tbl.Columns.Count-1].AllowDBNull = false;
+ Assert.Fail("NNAE9: Columns failed to raise DataException.");
+ }
+ catch (DataException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE10: Columns wrong exception type. Got: " + exc);
+ }
+
+ //clear table data in order to add the new column
+ tbl.Rows.Clear();
+ tbl.Columns[tbl.Columns.Count-1].AllowDBNull = false;
+ tbl.Rows.Add(new object[] {99,"value","value",new DateTime(0),0.5,true,false}); //missing last value - will be null
+
+ //add new row with null value
+ // NoNullAllowedException - Add Row
+ try
+ {
+ tbl.Rows.Add(new object[] {99,"value","value",new DateTime(0),0.5,true}); //missing last value - will be null
+ Assert.Fail("NNAE11: Rows.Add failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE12: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ //add new row with DBNull value
+ // NoNullAllowedException - Add Row
+ try
+ {
+ tbl.Rows.Add(new object[] {1,"value","value",new DateTime(0),0.5,true,DBNull.Value});
+ Assert.Fail("NNAE13: Rows.Add failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE14: Rows.Add wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - ItemArray
+ try
+ {
+ tbl.Rows[0].ItemArray = new object[] {77,"value","value",new DateTime(0),0.5,true,DBNull.Value };
+ Assert.Fail("NNAE15: Rows Indexer failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE16: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - Add Row - LoadDataRow
+ try
+ {
+ tbl.LoadDataRow(new object[] {66,"value","value",new DateTime(0),0.5,true},true);
+ Assert.Fail("NNAE17: LoadDataRow failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE18: Rows.LoadDataRow wrong exception type. Got: " + exc);
+ }
+
+ // NoNullAllowedException - EndEdit
+ tbl.Rows[0].BeginEdit();
+ tbl.Rows[0][tbl.Columns.Count-1] = DBNull.Value ;
+ try
+ {
+ tbl.Rows[0].EndEdit();
+ Assert.Fail("NNAE19: Rows[0].EndEdit failed to raise NoNullAllowedException.");
+ }
+ catch (NoNullAllowedException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("NNAE20: Rows[0].EndEdit wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class ReadOnlyExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ Exception tmpEx = new Exception() ;
+
+ DataTable tbl = DataProvider.CreateParentDataTable();
+ tbl.Columns[0].ReadOnly = true;
+
+ //chaeck for int column
+ // ReadOnlyException - EndEdit
+ //tbl.Rows[0].BeginEdit(); // this throw an exception but according to MSDN it shouldn't !!!
+ //tbl.Rows[0][0] = 99 ;
+ try
+ {
+ tbl.Rows[0][0] = 99 ;
+ //tbl.Rows[0].EndEdit();
+ Assert.Fail("ROE1: Rows Indexer failed to raise ReadOnlyException.");
+ }
+ catch (ReadOnlyException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ROE2: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ // ReadOnlyException - ItemArray
+ try
+ {
+ tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
+ Assert.Fail("ROE3: Rows[0].ItemArray failed to raise ReadOnlyException.");
+ }
+ catch (ReadOnlyException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ROE4: Rows[0].ItemArray wrong exception type. Got: " + exc);
+ }
+
+ //chaeck for string column
+ tbl.Columns[0].ReadOnly = false;
+ tbl.Columns[1].ReadOnly = true;
+
+ // ReadOnlyException - EndEdit
+ //tbl.Rows[0].BeginEdit(); // this throw an exception but according to MSDN it shouldn't !!!
+ //tbl.Rows[0][0] = 99 ;
+ try
+ {
+ tbl.Rows[0][1] = "NewValue" ;
+ //tbl.Rows[0].EndEdit();
+ Assert.Fail("ROE5: Rows Indexer failed to raise ReadOnlyException.");
+ }
+ catch (ReadOnlyException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ROE6: Rows Indexer wrong exception type. Got: " + exc);
+ }
+
+ // ReadOnlyException - ItemArray
+ try
+ {
+ tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
+ Assert.Fail("ROE7: Rows[0].ItemArray failed to raise ReadOnlyException.");
+ }
+ catch (ReadOnlyException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("ROE8: Rows[0].ItemArray wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Data;
+using MonoTests.System.Data.Test.Utils;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class RowNotInTableExceptionTest
+ {
+ [Test]
+ public void Generate()
+ {
+ DataSet ds = new DataSet();
+ ds.Tables.Add(DataProvider.CreateParentDataTable());
+ ds.Tables.Add(DataProvider.CreateChildDataTable());
+ ds.Relations.Add(new DataRelation("myRelation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
+
+ DataRow drParent = ds.Tables[0].Rows[0];
+ DataRow drChild = ds.Tables[1].Rows[0];
+ drParent.Delete();
+ drChild.Delete();
+ ds.AcceptChanges();
+
+ // RowNotInTableException - AcceptChanges
+ try
+ {
+ drParent.AcceptChanges();
+ Assert.Fail("RNT1: AcceptChanges failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: AcceptChanges wrong exception type. Got: " + exc);
+ }
+
+ // RowNotInTableException - GetChildRows
+ try
+ {
+ drParent.GetChildRows("myRelation");
+ Assert.Fail("RNT1: GetChildRows failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: GetChildRows wrong exception type. Got: " + exc);
+ }
+
+ // RowNotInTableException - ItemArray
+ object[] o = null;
+ try
+ {
+ o = drParent.ItemArray ;
+ Assert.Fail("RNT1: ItemArray failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: ItemArray wrong exception type. Got: " + exc);
+ }
+
+ // ********** don't throw exception (should be according to MSDN) ***********************
+ // // RowNotInTableException - GetParentRow
+ // try
+ // {
+ // DataRow dr = null;
+ // dr = drChild.GetParentRow("myRelation");
+ // Assert.Fail("RNT1: GetParentRow failed to raise (RowNotInTableException.");
+ // }
+ // catch (RowNotInTableException) {}
+ // catch (AssertionException) { throw; }
+ // catch (Exception exc)
+ // {
+ // Assert.Fail("RNT2: GetParentRow wrong exception type. Got: " + exc);
+ // }
+
+ // RowNotInTableException - GetParentRows
+ DataRow[] dr = null;
+ try
+ {
+ dr = drChild.GetParentRows("myRelation");
+ Assert.Fail("RNT1: GetParentRows failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: GetParentRows wrong exception type. Got: " + exc);
+ }
+
+ // RowNotInTableException - RejectChanges
+ try
+ {
+ drParent.RejectChanges();
+ Assert.Fail("RNT1: RejectChanges failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: RejectChanges wrong exception type. Got: " + exc);
+ }
+
+ // RowNotInTableException - SetParentRow
+ try
+ {
+ drChild.SetParentRow(ds.Tables[0].Rows[1]);
+ Assert.Fail("RNT1: SetParentRow failed to raise (RowNotInTableException.");
+ }
+ catch (RowNotInTableException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("RNT2: SetParentRow wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}
--- /dev/null
+// 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.Text;
+using System.IO;
+using System.Data;
+
+namespace MonoTests_System.Data
+{
+ [TestFixture] public class SyntaxErrorExceptionTest
+ {
+ [Test] public void Generate()
+ {
+ Exception tmpEx = new Exception() ;
+
+ DataTable tbl = new DataTable();
+ tbl.Columns.Add(new DataColumn("Column"));
+ DataColumn dc = new DataColumn();
+ dc.Expression = "something"; //invalid expression
+
+ // SyntaxErrorException - Column Expression
+ try
+ {
+ tbl.Columns[0].Expression = "Colummn +=+ 1"; //invalid expression
+ Assert.Fail("SEE1: Columns[0].Expression failed to raise SyntaxErrorException.");
+ }
+ catch (SyntaxErrorException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("SEE2: Columns[0].Expression wrong exception type. Got: " + exc);
+ }
+ // SyntaxErrorException - Select
+ try
+ {
+ tbl.Select("Name += bulshit");
+ Assert.Fail("SEE3: Select failed to raise SyntaxErrorException.");
+ }
+ catch (SyntaxErrorException) {}
+ catch (AssertionException) { throw; }
+ catch (Exception exc)
+ {
+ Assert.Fail("SEE4: Select wrong exception type. Got: " + exc);
+ }
+ }
+ }
+}