2 // Copyright (c) 2006 Mainsoft Co.
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 using System.Data.OleDb;
28 using MonoTests.System.Data.Utils;
31 using NUnit.Framework;
33 namespace MonoTests.System.Data.OleDb
36 public class OleDbDataReader_GetValues : ADONetTesterClass
38 public static void Main()
40 OleDbDataReader_GetValues tc = new OleDbDataReader_GetValues();
44 tc.BeginTest("OleDbDataReader_GetValues");
47 catch(Exception ex){exp = ex;}
48 finally {tc.EndTest(exp);}
55 int intValuesCount = 0;
58 base.PrepareDataForTesting(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
60 OleDbConnection con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
62 OleDbCommand cmd = new OleDbCommand("Select CustomerID, ContactName , CompanyName From Customers where CustomerID = 'GH100'", con);
63 OleDbDataReader rdr = cmd.ExecuteReader();
66 object [] values = null;
69 //------ check big array
72 BeginCase("GetValues - bigger array - check count");
73 values = new object[50];
74 intValuesCount = rdr.GetValues(values);
75 Compare(intValuesCount ,3 );
77 catch(Exception ex){exp = ex;}
78 finally{EndCase(exp); exp = null;}
82 BeginCase("GetValues - bigger array - check CustomerID");
83 Compare(values[0].ToString().Trim() ,"GH100" );
85 catch(Exception ex){exp = ex;}
86 finally{EndCase(exp); exp = null;}
90 BeginCase("GetValues - bigger array - check CompanyName");
91 Compare(values[2].ToString() ,"Company100" );
93 catch(Exception ex){exp = ex;}
94 finally{EndCase(exp); exp = null;}
98 BeginCase("GetValues - bigger array - check DBNull");
99 Compare(values[3] == null ,true);
101 catch(Exception ex){exp = ex;}
102 finally{EndCase(exp); exp = null;}
104 //------ check small array
107 BeginCase("GetValues - smaller array - check count");
108 values = new object[2];
109 intValuesCount = rdr.GetValues(values);
110 Compare(intValuesCount ,2 );
112 catch(Exception ex){exp = ex;}
113 finally{EndCase(exp); exp = null;}
117 BeginCase("GetValues - smaller array - check CustomerID");
118 Compare(values[0].ToString().Trim() ,"GH100" );
120 catch(Exception ex){exp = ex;}
121 finally{EndCase(exp); exp = null;}
124 //------ check exact array
127 BeginCase("GetValues - exact array - check count");
128 values = new object[3];
129 intValuesCount = rdr.GetValues(values);
130 Compare(intValuesCount ,3 );
132 catch(Exception ex){exp = ex;}
133 finally{EndCase(exp); exp = null;}
137 BeginCase("GetValues - exact array - check CustomerID");
138 Compare(values[0].ToString().Trim() ,"GH100" );
140 catch(Exception ex){exp = ex;}
141 finally{EndCase(exp); exp = null;}
145 BeginCase("GetValues - exact array - check CompanyName");
146 Compare(values[2].ToString() ,"Company100" );
148 catch(Exception ex){exp = ex;}
149 finally{EndCase(exp); exp = null;}
151 if (con.State == ConnectionState.Open) con.Close();