1 // DbDataReaderTest.cs - NUnit Test Cases for testing the
2 // DbDataReader family of classes
5 // Gert Driesen (drieseng@users.sourceforge.net)
7 // Copyright (c) 2008 Gert Driesen
9 // Permission is hereby granted, free of charge, to any person
10 // obtaining a copy of this software and associated documentation
11 // files (the "Software"), to deal in the Software without
12 // restriction, including without limitation the rights to use, copy,
13 // modify, merge, publish, distribute, sublicense, and/or sell copies
14 // of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to 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
24 // BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 using System.Data.Common;
33 using System.Data.Odbc;
34 using System.Data.SqlClient;
35 using System.Data.SqlTypes;
36 using System.Globalization;
40 using NUnit.Framework;
42 namespace MonoTests.System.Data
46 [Category ("sqlserver")]
47 public class DbDataReaderTest
56 conn = ConnectionManager.Singleton.Connection;
57 ConnectionManager.Singleton.OpenConnection ();
58 cmd = conn.CreateCommand ();
62 public void TearDown ()
68 ConnectionManager.Singleton.CloseConnection ();
72 public void GetProviderSpecificValues_Reader_Closed ()
74 cmd.CommandText = "SELECT * FROM employee";
75 rdr = cmd.ExecuteReader ();
79 rdr.GetProviderSpecificValues (null);
81 } catch (InvalidOperationException ex) {
82 // Invalid attempt to call MetaData
83 // when reader is closed
84 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
85 Assert.IsNull (ex.InnerException, "#3");
86 Assert.IsNotNull (ex.Message, "#4");
91 public void GetProviderSpecificValues_Reader_NoData ()
93 cmd.CommandText = "SELECT * FROM employee where id = 6666";
94 rdr = cmd.ExecuteReader ();
97 rdr.GetProviderSpecificValues (null);
99 } catch (InvalidOperationException ex) {
100 // Invalid attempt to read when no data
102 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
103 Assert.IsNull (ex.InnerException, "#A3");
104 Assert.IsNotNull (ex.Message, "#A4");
107 Assert.IsFalse (rdr.Read (), "B");
110 rdr.GetProviderSpecificValues (null);
112 } catch (InvalidOperationException ex) {
113 // Invalid attempt to read when no data
115 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
116 Assert.IsNull (ex.InnerException, "#C3");
117 Assert.IsNotNull (ex.Message, "#C4");