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;
32 using MonoTests.System.Data.Utils;
34 namespace MonoTests_System.Data
36 [TestFixture] public class RowNotInTableExceptionTest
39 public void Generate()
41 DataSet ds = new DataSet();
42 ds.Tables.Add(DataProvider.CreateParentDataTable());
43 ds.Tables.Add(DataProvider.CreateChildDataTable());
44 ds.Relations.Add(new DataRelation("myRelation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
46 DataRow drParent = ds.Tables[0].Rows[0];
47 DataRow drChild = ds.Tables[1].Rows[0];
52 // RowNotInTableException - AcceptChanges
55 drParent.AcceptChanges();
56 Assert.Fail("RNT1: AcceptChanges failed to raise (RowNotInTableException.");
58 catch (RowNotInTableException) {}
59 catch (AssertionException) { throw; }
62 Assert.Fail("RNT2: AcceptChanges wrong exception type. Got: " + exc);
65 // RowNotInTableException - GetChildRows
68 drParent.GetChildRows("myRelation");
69 Assert.Fail("RNT1: GetChildRows failed to raise (RowNotInTableException.");
71 catch (RowNotInTableException) {}
72 catch (AssertionException) { throw; }
75 Assert.Fail("RNT2: GetChildRows wrong exception type. Got: " + exc);
78 // RowNotInTableException - ItemArray
82 o = drParent.ItemArray ;
83 Assert.Fail("RNT1: ItemArray failed to raise (RowNotInTableException.");
85 catch (RowNotInTableException) {}
86 catch (AssertionException) { throw; }
89 Assert.Fail("RNT2: ItemArray wrong exception type. Got: " + exc);
92 // ********** don't throw exception (should be according to MSDN) ***********************
93 // // RowNotInTableException - GetParentRow
97 // dr = drChild.GetParentRow("myRelation");
98 // Assert.Fail("RNT1: GetParentRow failed to raise (RowNotInTableException.");
100 // catch (RowNotInTableException) {}
101 // catch (AssertionException) { throw; }
102 // catch (Exception exc)
104 // Assert.Fail("RNT2: GetParentRow wrong exception type. Got: " + exc);
107 // RowNotInTableException - GetParentRows
111 dr = drChild.GetParentRows("myRelation");
112 Assert.Fail("RNT1: GetParentRows failed to raise (RowNotInTableException.");
114 catch (RowNotInTableException) {}
115 catch (AssertionException) { throw; }
116 catch (Exception exc)
118 Assert.Fail("RNT2: GetParentRows wrong exception type. Got: " + exc);
121 // RowNotInTableException - RejectChanges
124 drParent.RejectChanges();
125 Assert.Fail("RNT1: RejectChanges failed to raise (RowNotInTableException.");
127 catch (RowNotInTableException) {}
128 catch (AssertionException) { throw; }
129 catch (Exception exc)
131 Assert.Fail("RNT2: RejectChanges wrong exception type. Got: " + exc);
134 // RowNotInTableException - SetParentRow
137 drChild.SetParentRow(ds.Tables[0].Rows[1]);
138 Assert.Fail("RNT1: SetParentRow failed to raise (RowNotInTableException.");
140 catch (RowNotInTableException) {}
141 catch (AssertionException) { throw; }
142 catch (Exception exc)
144 Assert.Fail("RNT2: SetParentRow wrong exception type. Got: " + exc);