2 // Rafael Mizrahi <rafim@mainsoft.com>
3 // Erez Lotan <erezl@mainsoft.com>
4 // Oren Gurfinkel <oreng@mainsoft.com>
7 // Copyright (c) 2004 Mainsoft Co.
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using NUnit.Framework;
34 using MonoTests.System.Data.Utils;
36 namespace MonoTests_System.Data
38 [TestFixture] public class ReadOnlyExceptionTest
40 [Test] public void Generate()
42 Exception tmpEx = new Exception() ;
44 DataTable tbl = DataProvider.CreateParentDataTable();
45 tbl.Columns[0].ReadOnly = true;
47 //chaeck for int column
48 // ReadOnlyException - EndEdit
49 //tbl.Rows[0].BeginEdit(); // this throw an exception but according to MSDN it shouldn't !!!
50 //tbl.Rows[0][0] = 99 ;
54 //tbl.Rows[0].EndEdit();
55 Assert.Fail("ROE1: Rows Indexer failed to raise ReadOnlyException.");
57 catch (ReadOnlyException) {}
58 catch (AssertionException) { throw; }
61 Assert.Fail("ROE2: Rows Indexer wrong exception type. Got: " + exc);
64 // ReadOnlyException - ItemArray
67 tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
68 Assert.Fail("ROE3: Rows[0].ItemArray failed to raise ReadOnlyException.");
70 catch (ReadOnlyException) {}
71 catch (AssertionException) { throw; }
74 Assert.Fail("ROE4: Rows[0].ItemArray wrong exception type. Got: " + exc);
77 //chaeck for string column
78 tbl.Columns[0].ReadOnly = false;
79 tbl.Columns[1].ReadOnly = true;
81 // ReadOnlyException - EndEdit
82 //tbl.Rows[0].BeginEdit(); // this throw an exception but according to MSDN it shouldn't !!!
83 //tbl.Rows[0][0] = 99 ;
86 tbl.Rows[0][1] = "NewValue" ;
87 //tbl.Rows[0].EndEdit();
88 Assert.Fail("ROE5: Rows Indexer failed to raise ReadOnlyException.");
90 catch (ReadOnlyException) {}
91 catch (AssertionException) { throw; }
94 Assert.Fail("ROE6: Rows Indexer wrong exception type. Got: " + exc);
97 // ReadOnlyException - ItemArray
100 tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
101 Assert.Fail("ROE7: Rows[0].ItemArray failed to raise ReadOnlyException.");
103 catch (ReadOnlyException) {}
104 catch (AssertionException) { throw; }
105 catch (Exception exc)
107 Assert.Fail("ROE8: Rows[0].ItemArray wrong exception type. Got: " + exc);