[System.Net] Add support for .pac proxy config scripts on mac
[mono.git] / mcs / class / System.Data / Test / System.Data / ReadOnlyExceptionTest.cs
1 // Authors:
2 //   Rafael Mizrahi   <rafim@mainsoft.com>
3 //   Erez Lotan       <erezl@mainsoft.com>
4 //   Oren Gurfinkel   <oreng@mainsoft.com>
5 //   Ofer Borstein
6 //
7 // Copyright (c) 2004 Mainsoft Co.
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
27 //
28
29 using NUnit.Framework;
30 using System;
31 using System.Text;
32 using System.IO;
33 using System.Data;
34 using MonoTests.System.Data.Utils;
35
36 namespace MonoTests_System.Data
37 {
38         [TestFixture] public class ReadOnlyExceptionTest
39         {
40                 [Test] public void Generate()
41                 {
42                         Exception tmpEx = new Exception() ;
43
44                         DataTable tbl = DataProvider.CreateParentDataTable();
45                         tbl.Columns[0].ReadOnly = true;
46
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 ;
51                         try 
52                         {
53                                 tbl.Rows[0][0] = 99 ;
54                                 //tbl.Rows[0].EndEdit();
55                                 Assert.Fail("ROE1: Rows Indexer failed to raise ReadOnlyException.");
56                         }
57                         catch (ReadOnlyException) {}
58                         catch (AssertionException) { throw; }
59                         catch (Exception exc)
60                         {
61                                 Assert.Fail("ROE2: Rows Indexer wrong exception type. Got: " + exc);
62                         }
63
64                         // ReadOnlyException - ItemArray
65                         try 
66                         {
67                                 tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
68                                 Assert.Fail("ROE3: Rows[0].ItemArray failed to raise ReadOnlyException.");
69                         }
70                         catch (ReadOnlyException) {}
71                         catch (AssertionException) { throw; }
72                         catch (Exception exc)
73                         {
74                                 Assert.Fail("ROE4: Rows[0].ItemArray wrong exception type. Got: " + exc);
75                         }
76
77                         //chaeck for string column
78                         tbl.Columns[0].ReadOnly = false;
79                         tbl.Columns[1].ReadOnly = true;
80
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 ;
84                         try 
85                         {
86                                 tbl.Rows[0][1] = "NewValue" ;
87                                 //tbl.Rows[0].EndEdit();
88                                 Assert.Fail("ROE5: Rows Indexer failed to raise ReadOnlyException.");
89                         }
90                         catch (ReadOnlyException) {}
91                         catch (AssertionException) { throw; }
92                         catch (Exception exc)
93                         {
94                                 Assert.Fail("ROE6: Rows Indexer wrong exception type. Got: " + exc);
95                         }
96
97                         // ReadOnlyException - ItemArray
98                         try 
99                         {
100                                 tbl.Rows[0].ItemArray = new object[] {99,"value","value"};
101                                 Assert.Fail("ROE7: Rows[0].ItemArray failed to raise ReadOnlyException.");
102                         }
103                         catch (ReadOnlyException) {}
104                         catch (AssertionException) { throw; }
105                         catch (Exception exc)
106                         {
107                                 Assert.Fail("ROE8: Rows[0].ItemArray wrong exception type. Got: " + exc);
108                         }
109                 }
110         }
111 }