Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -29,9 +29,7 @@
using System;
using System.Data;
#if NET_2_0
using System.Data.Sql;
#endif
using System.Data.SqlClient;
using NUnit.Framework;
@ -53,10 +51,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#4");
Assert.IsNull (cmd.Container, "#5");
Assert.IsTrue (cmd.DesignTimeVisible, "#6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#8");
#endif
Assert.IsNotNull (cmd.Parameters, "#9");
Assert.AreEqual (0, cmd.Parameters.Count, "#10");
Assert.IsNull (cmd.Site, "#11");
@ -74,10 +70,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
#endif
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@ -91,10 +85,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
#endif
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@ -115,10 +107,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
#endif
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@ -132,10 +122,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
#endif
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@ -149,10 +137,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#C7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
#endif
Assert.IsNotNull (cmd.Parameters, "#C9");
Assert.AreEqual (0, cmd.Parameters.Count, "#C10");
Assert.IsNull (cmd.Site, "#C11");
@ -173,10 +159,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#A7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#A8");
#endif
Assert.IsNotNull (cmd.Parameters, "#A9");
Assert.AreEqual (0, cmd.Parameters.Count, "#A10");
Assert.IsNull (cmd.Site, "#A11");
@ -190,10 +174,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#B7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#B8");
#endif
Assert.IsNotNull (cmd.Parameters, "#B9");
Assert.AreEqual (0, cmd.Parameters.Count, "#B10");
Assert.IsNull (cmd.Site, "#B11");
@ -207,10 +189,8 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
#if NET_2_0
Assert.IsNull (cmd.Notification, "#C7");
Assert.IsTrue (cmd.NotificationAutoEnlist, "#C8");
#endif
Assert.IsNotNull (cmd.Parameters, "#C9");
Assert.AreEqual (0, cmd.Parameters.Count, "#C10");
Assert.IsNull (cmd.Site, "#C11");
@ -221,26 +201,18 @@ namespace MonoTests.System.Data.SqlClient
[Test]
public void Clone ()
{
#if NET_2_0
SqlNotificationRequest notificationReq = new SqlNotificationRequest ();
#endif
SqlCommand cmd = new SqlCommand ();
cmd.CommandText = "sp_insert";
cmd.CommandTimeout = 100;
cmd.CommandType = CommandType.StoredProcedure;
cmd.DesignTimeVisible = false;
#if NET_2_0
cmd.Notification = notificationReq;
cmd.NotificationAutoEnlist = false;
#endif
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
cmd.Parameters ["@TestPar1"].Value = DBNull.Value;
#if NET_2_0
cmd.Parameters.AddWithValue ("@BirthDate", DateTime.Now);
#else
cmd.Parameters.Add ("@BirthDate", DateTime.Now);
#endif
cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;
SqlCommand clone = (((ICloneable) (cmd)).Clone ()) as SqlCommand;
@ -249,17 +221,11 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreEqual (CommandType.StoredProcedure, clone.CommandType, "#3");
Assert.IsNull (cmd.Connection, "#4");
Assert.IsFalse (cmd.DesignTimeVisible, "#5");
#if NET_2_0
Assert.AreSame (notificationReq, cmd.Notification, "#6");
Assert.IsFalse (cmd.NotificationAutoEnlist, "#7");
#endif
Assert.AreEqual (2, clone.Parameters.Count, "#8");
Assert.AreEqual (100, clone.CommandTimeout, "#9");
#if NET_2_0
clone.Parameters.AddWithValue ("@test", DateTime.Now);
#else
clone.Parameters.Add ("@test", DateTime.Now);
#endif
clone.Parameters [0].ParameterName = "@ClonePar1";
Assert.AreEqual (3, clone.Parameters.Count, "#10");
Assert.AreEqual (2, cmd.Parameters.Count, "#11");
@ -308,11 +274,7 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
#if NET_2_0
Assert.AreEqual ("CommandTimeout", ex.ParamName, "#5");
#else
Assert.IsNull (ex.ParamName, "#5");
#endif
}
}
@ -323,7 +285,6 @@ namespace MonoTests.System.Data.SqlClient
try {
cmd.CommandType = (CommandType) (666);
Assert.Fail ("#1");
#if NET_2_0
} catch (ArgumentOutOfRangeException ex) {
// The CommandType enumeration value, 666, is invalid
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
@ -332,16 +293,6 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#5");
Assert.AreEqual ("CommandType", ex.ParamName, "#6");
}
#else
} catch (ArgumentException ex) {
// The CommandType enumeration value, 666, is invalid
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#5");
Assert.IsNull (ex.ParamName, "#6");
}
#endif
}
[Test] // bug #324386
@ -451,11 +402,7 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
#if NET_2_0
Assert.IsTrue (ex.Message.IndexOf ("ExecuteScalar") != -1, "#5");
#else
Assert.IsTrue (ex.Message.IndexOf ("ExecuteReader") != -1, "#5");
#endif
}
}
@ -472,11 +419,7 @@ namespace MonoTests.System.Data.SqlClient
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
#if NET_2_0
Assert.IsTrue (ex.Message.StartsWith ("ExecuteScalar:"), "#5");
#else
Assert.IsTrue (ex.Message.StartsWith ("ExecuteReader:"), "#5");
#endif
}
}
@ -487,15 +430,11 @@ namespace MonoTests.System.Data.SqlClient
// Text, without parameters
cmd = new SqlCommand ("select count(*) from whatever");
#if NET_2_0
try {
cmd.Prepare ();
Assert.Fail ("#A1");
} catch (NullReferenceException) {
}
#else
cmd.Prepare ();
#endif
// Text, with parameters
cmd = new SqlCommand ("select count(*) from whatever");
@ -503,59 +442,37 @@ namespace MonoTests.System.Data.SqlClient
try {
cmd.Prepare ();
Assert.Fail ("#B1");
#if NET_2_0
} catch (NullReferenceException) {
}
#else
} catch (InvalidOperationException ex) {
// Prepare: Connection property has not been
// initialized
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
#endif
// Text, without parameters
cmd = new SqlCommand ("select count(*) from whatever");
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
cmd.Parameters.Clear ();
#if NET_2_0
try {
cmd.Prepare ();
Assert.Fail ("#C1");
} catch (NullReferenceException) {
}
#else
cmd.Prepare ();
#endif
// StoredProcedure, without parameters
cmd = new SqlCommand ("FindCustomer");
cmd.CommandType = CommandType.StoredProcedure;
#if NET_2_0
try {
cmd.Prepare ();
Assert.Fail ("#D1");
} catch (NullReferenceException) {
}
#else
cmd.Prepare ();
#endif
// StoredProcedure, with parameters
cmd = new SqlCommand ("FindCustomer");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add ("@TestPar1", SqlDbType.Int);
#if NET_2_0
try {
cmd.Prepare ();
Assert.Fail ("#E1");
} catch (NullReferenceException) {
}
#else
cmd.Prepare ();
#endif
}
[Test] // bug #412586
@ -635,7 +552,6 @@ namespace MonoTests.System.Data.SqlClient
try {
cmd.UpdatedRowSource = (UpdateRowSource) 666;
Assert.Fail ("#1");
#if NET_2_0
} catch (ArgumentOutOfRangeException ex) {
// The UpdateRowSource enumeration value,666,
// is invalid
@ -644,27 +560,15 @@ namespace MonoTests.System.Data.SqlClient
Assert.IsNotNull (ex.Message, "#4");
Assert.AreEqual ("UpdateRowSource", ex.ParamName, "#5");
}
#else
} catch (ArgumentException ex) {
// The UpdateRowSource enumeration value, 666,
// is invalid
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNull (ex.ParamName, "#5");
}
#endif
}
#if NET_2_0
[Test] // bug #381100
public void ParameterCollectionTest ()
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddRange(new SqlParameter[] { });
}
#endif
}
}