Modified:
branches/5.0/TestSuite/Source/BaseTest.cs
branches/5.0/TestSuite/Source/CommandBuilderTests.cs
branches/5.0/TestSuite/Source/DataReaderTests.cs
branches/5.0/TestSuite/Source/StoredProcedure.cs
branches/5.0/TestSuite/Source/StressTests.cs
branches/5.0/TestSuite/Source/Syntax.cs
Log:
basetest --
Replaced the algorithm for determining the database names. The previous code did a simple random name. This just resulted in old databases left over from bad runs. This code takes the version of the executing assembly, combines it with part of the port being targeted, and tacks on -a and -b for the two databases. This should allow all my testing scenarios to run and not conflict and also prevent database clutter.
other files --
The rest of the changes were just test cases that did not work with database names that require ticks
Modified: branches/5.0/TestSuite/Source/BaseTest.cs
===================================================================
--- branches/5.0/TestSuite/Source/BaseTest.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/BaseTest.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -23,6 +23,8 @@
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;
+using System.Reflection;
+using System.Diagnostics;
namespace MySql.Data.MySqlClient.Tests
{
@@ -43,45 +45,45 @@
protected string memoryName;
protected string rootUser;
protected string rootPassword;
- protected string database0;
- protected string database1;
+ protected static string database0;
+ protected static string database1;
public BaseTest()
{
csAdditions = ";pooling=false;";
user = "test";
password = "test";
- host = "localhost";
port = 3306;
- pipeName = "MYSQL";
- memoryName = "MYSQL";
rootUser = "root";
rootPassword = "";
- database0 = System.IO.Path.GetFileNameWithoutExtension(
- System.IO.Path.GetTempFileName());
- database1 = System.IO.Path.GetFileNameWithoutExtension(
- System.IO.Path.GetTempFileName());
-
#if NET20
- string strHost = ConfigurationManager.AppSettings["host"];
+ host = ConfigurationManager.AppSettings["host"];
string strPort = ConfigurationManager.AppSettings["port"];
- string strPipeName = ConfigurationManager.AppSettings["pipename"];
- string strMemName = ConfigurationManager.AppSettings["memory_name"];
+ pipeName = ConfigurationManager.AppSettings["pipename"];
+ memoryName = ConfigurationManager.AppSettings["memory_name"];
#else
- string strHost = ConfigurationSettings.AppSettings["host"];
+ host = ConfigurationSettings.AppSettings["host"];
string strPort = ConfigurationSettings.AppSettings["port"];
- string strPipeName = ConfigurationSettings.AppSettings["pipename"];
- string strMemName = ConfigurationSettings.AppSettings["memory_name"];
+ pipeName = ConfigurationSettings.AppSettings["pipename"];
+ memoryName = ConfigurationSettings.AppSettings["memory_name"];
#endif
- if (strHost != null)
- host = strHost;
if (strPort != null)
port = Int32.Parse(strPort);
- if (strPipeName != null)
- pipeName = strPipeName;
- if (strMemName != null)
- memoryName = strMemName;
+ if (host == null)
+ host = "localhost";
+ if (pipeName == null)
+ pipeName = "MYSQL";
+ if (memoryName == null)
+ memoryName = "MYSQL";
+
+ if (database0 == null)
+ {
+ Assembly a = Assembly.GetExecutingAssembly();
+ FileVersionInfo fv = FileVersionInfo.GetVersionInfo(a.Location);
+ database0 = String.Format("db{0}{1}{2}-a", fv.FileMajorPart, fv.FileMinorPart, port-3300);
+ database1 = String.Format("db{0}{1}{2}-b", fv.FileMajorPart, fv.FileMinorPart, port-3300);
+ }
}
[TestFixtureSetUp]
@@ -95,8 +97,8 @@
rootConn.Open();
// now create our databases
- suExecSQL("CREATE DATABASE `" + database0 + "`");
- suExecSQL("CREATE DATABASE `" + database1 + "`");
+ suExecSQL(String.Format("DROP DATABASE IF EXISTS `{0}`; CREATE DATABASE `{0}`", database0));
+ suExecSQL(String.Format("DROP DATABASE IF EXISTS `{0}`; CREATE DATABASE `{0}`", database1));
// now allow our user to access them
suExecSQL(String.Format(@"GRANT ALL ON `{0}`.* to 'test'@'localhost'
@@ -117,8 +119,8 @@
[TestFixtureTearDown]
protected virtual void TestFixtureTearDown()
{
- suExecSQL("DROP DATABASE " + database0);
- suExecSQL("DROP DATABASE " + database1);
+ suExecSQL(String.Format("DROP DATABASE IF EXISTS `{0}`", database0));
+ suExecSQL(String.Format("DROP DATABASE IF EXISTS `{0}`", database1));
rootConn.Close();
Close();
Modified: branches/5.0/TestSuite/Source/CommandBuilderTests.cs
===================================================================
--- branches/5.0/TestSuite/Source/CommandBuilderTests.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/CommandBuilderTests.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -176,7 +176,7 @@
conn.ChangeDatabase(database1);
MySqlDataAdapter da = new MySqlDataAdapter(
- String.Format("SELECT id, name FROM {0}.test", database0), conn);
+ String.Format("SELECT id, name FROM `{0}`.test", database0), conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
Modified: branches/5.0/TestSuite/Source/DataReaderTests.cs
===================================================================
--- branches/5.0/TestSuite/Source/DataReaderTests.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/DataReaderTests.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -394,7 +394,7 @@
[Test]
public void HungDataReader()
{
- MySqlCommand cmd = new MySqlCommand("USE " + database0 + "; SHOW TABLES", conn);
+ MySqlCommand cmd = new MySqlCommand("USE `" + database0 + "`; SHOW TABLES", conn);
MySqlDataReader reader = null;
try
{
@@ -788,7 +788,7 @@
execSQL("DROP TABLE IF EXISTS test");
execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))");
MySqlCommand cmd = new MySqlCommand(
- String.Format("SHOW INDEX FROM test FROM {0}", database0), conn);
+ String.Format("SHOW INDEX FROM test FROM `{0}`", database0), conn);
MySqlDataReader reader = null;
try
{
Modified: branches/5.0/TestSuite/Source/StoredProcedure.cs
===================================================================
--- branches/5.0/TestSuite/Source/StoredProcedure.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/StoredProcedure.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -463,7 +463,7 @@
try
{
c.Open();
- MySqlCommand cmd2 = new MySqlCommand(String.Format("use {0}", database0), c);
+ MySqlCommand cmd2 = new MySqlCommand(String.Format("use `{0}`", database0), c);
cmd2.ExecuteNonQuery();
MySqlCommand cmd = new MySqlCommand("spTest", c);
@@ -471,10 +471,10 @@
object val = cmd.ExecuteScalar();
Assert.AreEqual(4, val);
- cmd2.CommandText = String.Format("use {0}", database1);
+ cmd2.CommandText = String.Format("use `{0}`", database1);
cmd2.ExecuteNonQuery();
- cmd.CommandText = String.Format("{0}.spTest", database0);
+ cmd.CommandText = String.Format("`{0}`.spTest", database0);
val = cmd.ExecuteScalar();
Assert.AreEqual(4, val);
}
@@ -1005,10 +1005,10 @@
public void RunWithoutSelectPrivsThrowException()
{
suExecSQL(String.Format(
- "GRANT ALL ON {0}.* to 'testuser'@'%' identified by 'testuser'",
+ "GRANT ALL ON `{0}`.* to 'testuser'@'%' identified by 'testuser'",
database0));
suExecSQL(String.Format(
- "GRANT ALL ON {0}.* to 'testuser'@'localhost' identified by 'testuser'",
+ "GRANT ALL ON `{0}`.* to 'testuser'@'localhost' identified by 'testuser'",
database0));
execSQL("DROP PROCEDURE IF EXISTS spTest");
Modified: branches/5.0/TestSuite/Source/StressTests.cs
===================================================================
--- branches/5.0/TestSuite/Source/StressTests.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/StressTests.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -53,6 +53,7 @@
byte[] dataIn2 = Utils.CreateBlob(len);
MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )", conn);
+ cmd.CommandTimeout = 0;
cmd.Parameters.Add(new MySqlParameter("?id", 1));
cmd.Parameters.Add(new MySqlParameter("?blob", dataIn));
try
Modified: branches/5.0/TestSuite/Source/Syntax.cs
===================================================================
--- branches/5.0/TestSuite/Source/Syntax.cs 2007-08-15 22:31:23 UTC (rev 911)
+++ branches/5.0/TestSuite/Source/Syntax.cs 2007-08-16 02:40:02 UTC (rev 912)
@@ -446,7 +446,7 @@
public void ShowTableStatus()
{
MySqlDataAdapter da = new MySqlDataAdapter(
- String.Format("SHOW TABLE STATUS FROM {0} LIKE 'test'",
+ String.Format("SHOW TABLE STATUS FROM `{0}` LIKE 'test'",
database0), conn);
DataTable dt = new DataTable();
da.Fill(dt);
| Thread |
|---|
| • Connector/NET commit: r912 - branches/5.0/TestSuite/Source | rburnett | 16 Aug |