SqlCommand cmd = null;
SqlDataReader reader = null;
String query = "Select type_{0},type_{2},convert({1},null) from numeric_family where id=1";
- DataSet sqlDataset = null;
+ DataSet sqlDataset = null;
+ EngineConfig engine;
DataTable numericDataTable =null;
DataTable stringDataTable =null;
public void Setup ()
{
conn.Open ();
+ engine = ConnectionManager.Singleton.Engine;
}
+
[TearDown]
public void TearDown ()
{
conn.Close ();
}
-
+
[Test]
- public void ReadEmptyNTextFieldTest () {
+ public void ReadEmptyNTextFieldTest ()
+ {
try {
DBHelper.ExecuteNonQuery (conn, "create table #tmp_monotest (name ntext)");
DBHelper.ExecuteNonQuery (conn, "insert into #tmp_monotest values ('')");
} finally {
ConnectionManager.Singleton.CloseConnection ();
}
- }
+ }
[Test]
- public void ReadBingIntTest()
+ public void ReadBigIntTest()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
try {
string query = "SELECT CAST(548967465189498 AS bigint) AS Value";
SqlCommand cmd = new SqlCommand();
try {
CallGetMethod (s, 1);
- Assert.Fail ("#1[Get"+s+"] InvalidCastException must be thrown");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
- Assert.AreEqual (typeof(InvalidCastException), e.GetType(),
+ Assert.Fail ("#1[Get"+s+"] InvalidCastException must be thrown");
+ } catch (InvalidCastException e) {
+ Assert.AreEqual (typeof (InvalidCastException), e.GetType (),
"#2[Get"+s+"] Incorrect Exception : " + e);
}
if (!s.StartsWith("Sql")) {
try {
CallGetMethod (s, 2);
- Assert.Fail ("#3[Get"+s+"] Exception must be thrown");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e){
- Assert.AreEqual (typeof(SqlNullValueException),e.GetType(),
+ Assert.Fail ("#3[Get"+s+"] Exception must be thrown");
+ } catch (SqlNullValueException e) {
+ Assert.AreEqual (typeof (SqlNullValueException), e.GetType (),
"#4[Get"+s+"] Incorrect Exception : " + e);
}
}
try {
CallGetMethod (s, 3);
Assert.Fail ("#5[Get"+s+"] IndexOutOfRangeException must be thrown");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e){
- Assert.AreEqual (typeof(IndexOutOfRangeException), e.GetType(),
+ } catch (IndexOutOfRangeException e) {
+ Assert.AreEqual (typeof (IndexOutOfRangeException), e.GetType (),
"#6[Get"+s+"] Incorrect Exception : " + e);
}
}
[Test]
public void GetInt32Test ()
{
- cmd.CommandText = string.Format (query, "int", "int", "bigint");
+ if (ClientVersion == 7)
+ cmd.CommandText = string.Format (query, "int", "int", "decimal1");
+ else
+ cmd.CommandText = string.Format (query, "int", "int", "bigint");
+
reader = cmd.ExecuteReader ();
reader.Read ();
// Test for standard exceptions
[Test]
public void GetInt64Test ()
{
+ if (ClientVersion == 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = string.Format (query, "bigint", "bigint", "int");
reader = cmd.ExecuteReader ();
reader.Read ();
try {
reader.GetBytes (0, 0, null, 0, 0);
Assert.Fail ("#1");
- }catch (InvalidCastException ex) {
+ } catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.AreEqual ((new InvalidCastException ()).Message, ex.Message, "#4");
len = (int)reader.GetChars (0,0,null,0,0);
arr = new char [10];
- for (int i=0; i<len; ++i) {
- Assert.AreEqual (len-i, reader.GetChars (0, i, null, 0, 0), "#9_"+i);
- Assert.AreEqual (1, reader.GetChars (0, i, arr, 0, 1), "#10_"+i);
- Assert.AreEqual (charstring [i], arr [0], "#11_"+i);
+ for (int i = 0; i < len; ++i) {
+ Assert.AreEqual (len - i, reader.GetChars (0, i, null, 0, 0), "#9_" + i);
+ Assert.AreEqual (1, reader.GetChars (0, i, arr, 0, 1), "#10_" + i);
+ Assert.AreEqual (charstring [i], arr [0], "#11_" + i);
}
- Assert.AreEqual (0, reader.GetChars (0, len+10, null, 0, 0));
+ Assert.AreEqual (0, reader.GetChars (0, len + 10, null, 0, 0));
reader.Close ();
}
try {
reader.IsDBNull (10);
Assert.Fail ("#1 Invalid Argument");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
+ } catch (IndexOutOfRangeException e) {
Assert.AreEqual (typeof(IndexOutOfRangeException), e.GetType(),
"#1 Incorrect Exception : " + e);
}
try {
reader.Read ();
Assert.Fail ("#3 Exception shud be thrown : Reader is closed");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
+ } catch (InvalidOperationException e) {
Assert.AreEqual (typeof(InvalidOperationException), e.GetType (),
"#4 Incorrect Exception : " + e);
}
try {
reader.GetName (3);
Assert.Fail ("#4 Exception shud be thrown");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
+ } catch (IndexOutOfRangeException e) {
Assert.AreEqual (typeof(IndexOutOfRangeException), e.GetType(),
"#5 Incorrect Exception : " + e);
}
try {
reader.GetOrdinal ("invalidname");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
+ } catch (IndexOutOfRangeException e) {
Assert.AreEqual (typeof (IndexOutOfRangeException),
e.GetType(), "#4 Incorrect Exception : " + e);
}
Assert.AreEqual (0, row0["ColumnOrdinal"], "#2");
Assert.AreEqual (17, row0["ColumnSize"], "#3");
- Assert.AreEqual (38, row0["NumericPrecision"], "#4");
+ if (ClientVersion == 7)
+ Assert.AreEqual (28, row0["NumericPrecision"], "#4");
+ else
+ Assert.AreEqual (38, row0 ["NumericPrecision"], "#4");
Assert.AreEqual (0, row0["NumericScale"], "#5");
Assert.AreEqual (false, row0["IsUnique"], "#6");
try {
reader.GetSchemaTable ();
Assert.Fail ("#28 Exception shud be thrown" );
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
- Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
+ } catch (InvalidOperationException e) {
+ Assert.AreEqual (typeof (InvalidOperationException), e.GetType(),
"#29 Incorrect Exception");
}
}
try {
reader.GetDataTypeName (10);
Assert.Fail ("#4 Exception shud be thrown");
- }catch (AssertionException e) {
- throw e;
- }catch (Exception e) {
- Assert.AreEqual (typeof(IndexOutOfRangeException), e.GetType(),
+ } catch (IndexOutOfRangeException e) {
+ Assert.AreEqual (typeof (IndexOutOfRangeException), e.GetType (),
"#5 Incorrect Exception : " + e);
}
}
[Test]
public void GetFieldType_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
Assert.AreEqual (columns [i] [1], col.DataType, prefix + "DataType (" + i + ")");
}
}
+
+ int ClientVersion {
+ get {
+ return (engine.ClientVersion);
+ }
+ }
}
[TestFixture]
[Test]
public void ColumnSize_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
[Test]
public void DataType_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
[Test]
public void IsLong_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
[Test]
public void NumericPrecision_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
DataTable schemaTable = rdr.GetSchemaTable ();
DataRow row = schemaTable.Rows [0];
Assert.IsFalse (row.IsNull ("NumericPrecision"), "#A:IsNull");
- Assert.AreEqual (38, row ["NumericPrecision"], "#A:Value");
+ if (ClientVersion == 7)
+ Assert.AreEqual (28, row ["NumericPrecision"], "#A:Value");
+ else
+ Assert.AreEqual (38, row ["NumericPrecision"], "#A:Value");
}
cmd.CommandText = "SELECT type_decimal2 FROM numeric_family WHERE id = 1";
DataTable schemaTable = rdr.GetSchemaTable ();
DataRow row = schemaTable.Rows [0];
Assert.IsFalse (row.IsNull ("NumericPrecision"), "#C:IsNull");
- Assert.AreEqual (38, row ["NumericPrecision"], "#C:Value");
+ if (ClientVersion == 7)
+ Assert.AreEqual (28, row ["NumericPrecision"], "#C:Value");
+ else
+ Assert.AreEqual (38, row ["NumericPrecision"], "#C:Value");
}
cmd.CommandText = "SELECT type_numeric2 FROM numeric_family WHERE id = 1";
[Test]
public void NumericScale_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
[Test]
public void ProviderType_BigInt ()
{
+ if (ClientVersion <= 7)
+ Assert.Ignore ("BigInt data type is not supported.");
+
cmd.CommandText = "SELECT type_bigint FROM numeric_family WHERE id = 1";
using (SqlDataReader rdr = cmd.ExecuteReader (CommandBehavior.KeyInfo)) {
}
private int ClientVersion {
- get {
+ get {
return (engine.ClientVersion);
}
}