2 // SqlDataReaderTest.cs - NUnit Test Cases for testing the
5 // Umadevi S (sumadevi@novell.com)
6 // Kornél Pál <http://www.kornelpal.hu/>
7 // Sureshkumar T (tsureshkumar@novell.com)
9 // Copyright (c) 2004 Novell Inc., and the individuals listed
10 // on the ChangeLog entries.
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Data.Common;
35 using System.Data.SqlClient;
37 using NUnit.Framework;
39 namespace MonoTests.System.Data.SqlClient
43 [Category ("sqlserver")]
44 public class SqlDataReaderTest
49 public void ReadEmptyNTextFieldTest () {
50 conn = (SqlConnection) ConnectionManager.Singleton.Connection;
52 ConnectionManager.Singleton.OpenConnection ();
53 DBHelper.ExecuteNonQuery (conn, "create table #tmp_monotest (name ntext)");
54 DBHelper.ExecuteNonQuery (conn, "insert into #tmp_monotest values ('')");
56 SqlCommand cmd = (SqlCommand) conn.CreateCommand ();
57 cmd.CommandText = "select * from #tmp_monotest";
58 SqlDataReader dr = cmd.ExecuteReader ();
60 Assert.AreEqual("System.String",dr["NAME"].GetType().FullName);
62 Assert.AreEqual (false, dr.Read (), "#2");
64 ConnectionManager.Singleton.CloseConnection ();
69 public void ReadBingIntTest()
71 conn = (SqlConnection) ConnectionManager.Singleton.Connection;
73 ConnectionManager.Singleton.OpenConnection ();
74 string query = "SELECT CAST(548967465189498 AS bigint) AS Value";
75 SqlCommand cmd = new SqlCommand();
76 cmd.Connection = conn;
77 cmd.CommandText = query;
78 SqlDataReader r = cmd.ExecuteReader();
80 Assert.AreEqual (true, r.Read(), "#1");
81 long id = r.GetInt64(0);
82 Assert.AreEqual(548967465189498, id, "#2");
83 id = r.GetSqlInt64(0).Value;
84 Assert.AreEqual(548967465189498, id, "#3");
87 ConnectionManager.Singleton.CloseConnection ();