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;
36 using GHTUtils.Base;
\r
38 namespace tests.system_data_dll.System_Data
40 [TestFixture] public class RowNotInTableException_Generate : GHTBase
\r
42 [Test] public void Main()
\r
44 RowNotInTableException_Generate tc = new RowNotInTableException_Generate();
\r
45 Exception exp = null;
\r
48 tc.BeginTest("RowNotInTableException");
\r
61 //Activate This Construntor to log All To Standard output
\r
62 //public TestClass():base(true){}
\r
64 //Activate this constructor to log Failures to a log file
\r
65 //public TestClass(System.IO.TextWriter tw):base(tw, false){}
\r
68 //Activate this constructor to log All to a log file
\r
69 //public TestClass(System.IO.TextWriter tw):base(tw, true){}
\r
71 //BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
\r
75 Exception exp = null;
\r
76 Exception tmpEx = new Exception() ;
\r
78 DataSet ds = new DataSet();
\r
79 ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
\r
80 ds.Tables.Add(GHTUtils.DataProvider.CreateChildDataTable());
\r
81 ds.Relations.Add(new DataRelation("myRelation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
\r
83 DataRow drParent = ds.Tables[0].Rows[0];
\r
84 DataRow drChild = ds.Tables[1].Rows[0];
\r
91 BeginCase("RowNotInTableException - AcceptChanges");
\r
94 drParent.AcceptChanges();
\r
96 catch (RowNotInTableException ex)
\r
100 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
101 tmpEx = new Exception();
\r
103 catch(Exception ex) {exp = ex;}
\r
104 finally {EndCase(exp); exp = null;}
\r
108 BeginCase("RowNotInTableException - GetChildRows");
\r
111 drParent.GetChildRows("myRelation");
\r
113 catch (RowNotInTableException ex)
\r
117 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
118 tmpEx = new Exception();
\r
120 catch(Exception ex) {exp = ex;}
\r
121 finally {EndCase(exp); exp = null;}
\r
125 BeginCase("RowNotInTableException - ItemArray");
\r
129 o = drParent.ItemArray ;
\r
131 catch (RowNotInTableException ex)
\r
135 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
136 tmpEx = new Exception();
\r
138 catch(Exception ex) {exp = ex;}
\r
139 finally {EndCase(exp); exp = null;}
\r
141 // ********** don't throw exception (should be according to MSDN) ***********************
\r
144 // BeginCase("RowNotInTableException - GetParentRow");
\r
145 // DataRow dr = null;
\r
148 // dr = drChild.GetParentRow("myRelation");
\r
150 // catch (RowNotInTableException ex)
\r
154 // base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
155 // tmpEx = new Exception();
\r
157 // catch(Exception ex) {exp = ex;}
\r
158 // finally {EndCase(exp); exp = null;}
\r
162 BeginCase("RowNotInTableException - GetParentRows");
\r
163 DataRow[] dr = null;
\r
166 dr = drChild.GetParentRows("myRelation");
\r
168 catch (RowNotInTableException ex)
\r
172 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
173 tmpEx = new Exception();
\r
175 catch(Exception ex) {exp = ex;}
\r
176 finally {EndCase(exp); exp = null;}
\r
180 BeginCase("RowNotInTableException - RejectChanges");
\r
183 drParent.RejectChanges();
\r
185 catch (RowNotInTableException ex)
\r
189 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
190 tmpEx = new Exception();
\r
192 catch(Exception ex) {exp = ex;}
\r
193 finally {EndCase(exp); exp = null;}
\r
197 BeginCase("RowNotInTableException - SetParentRow");
\r
200 drChild.SetParentRow(ds.Tables[0].Rows[1]);
\r
202 catch (RowNotInTableException ex)
\r
206 base.Compare(tmpEx.GetType(),typeof(RowNotInTableException));
\r
207 tmpEx = new Exception();
\r
209 catch(Exception ex) {exp = ex;}
\r
210 finally {EndCase(exp); exp = null;}
\r