Commit 6ed2f3ba authored by Nick Craver's avatar Nick Craver

Add a MySQL test suite

TODO: Figure out a clean way to disable this locally - we'll want this
functionality in the Core test suite as well as we add MySQL specific
tests (due to syntax differences in creating tables and such).
parent 336cacbe
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.IO; using System.IO;
#if COREFX #if COREFX
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using IDbConnection = System.Data.Common.DbConnection; using IDbConnection = System.Data.Common.DbConnection;
#else #else
using System.Data.SQLite; using System.Data.SQLite;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using MySql.Data.MySqlClient;
using SqliteConnection = System.Data.SQLite.SQLiteConnection; using SqliteConnection = System.Data.SQLite.SQLiteConnection;
#endif #endif
...@@ -52,6 +52,44 @@ static SqlServerTestSuite() ...@@ -52,6 +52,44 @@ static SqlServerTestSuite()
} }
} }
#if !COREFX
public class MySqlServerTestSuite : TestSuite
{
const string DbName = "DapperContribTests";
public static string ConnectionString =>
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR"))
? @"Server=localhost;Uid=root;Pwd=Password12!;"
: $"Server=localhost;Uid=root;Pwd=Password12!;";
public override IDbConnection GetConnection() => new MySqlConnection(ConnectionString);
static MySqlServerTestSuite()
{
using (var connection = new MySqlConnection(ConnectionString))
{
// ReSharper disable once AccessToDisposedClosure
Action<string> dropTable = name => connection.Execute($@"DROP TABLE IF EXISTS `{name}`;");
connection.Open();
connection.Execute($@"DROP DATABASE IF EXISTS {DbName}; CREATE DATABASE {DbName}; USE {DbName};");
dropTable("Stuff");
connection.Execute(@"CREATE TABLE Stuff (TheId int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null, Created DateTime null);");
dropTable("People");
connection.Execute(@"CREATE TABLE People (Id int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null);");
dropTable("Users");
connection.Execute(@"CREATE TABLE Users (Id int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null, Age int not null);");
dropTable("Automobiles");
connection.Execute(@"CREATE TABLE Automobiles (Id int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null);");
dropTable("Results");
connection.Execute(@"CREATE TABLE Results (Id int not null AUTO_INCREMENT PRIMARY KEY, Name nvarchar(100) not null, `Order` int not null);");
dropTable("ObjectX");
connection.Execute(@"CREATE TABLE ObjectX (ObjectXId nvarchar(100) not null, Name nvarchar(100) not null);");
dropTable("ObjectY");
connection.Execute(@"CREATE TABLE ObjectY (ObjectYId int not null, Name nvarchar(100) not null);");
}
}
}
#endif
#if !COREFX && !DNX451 #if !COREFX && !DNX451
// This doesn't work on DNX right now due to: // This doesn't work on DNX right now due to:
// In Visual Studio: Interop loads (works from console, though) // In Visual Studio: Interop loads (works from console, though)
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
}, },
"dependencies": { "dependencies": {
"Microsoft.SqlServer.Compact": "4.0.8876.1", "Microsoft.SqlServer.Compact": "4.0.8876.1",
"MySql.Data": "6.9.8",
"System.Data.SQLite.Core": "1.0.98.1", "System.Data.SQLite.Core": "1.0.98.1",
"xunit": "1.9.2" "xunit": "1.9.2"
} }
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
}, },
"dependencies": { "dependencies": {
"Microsoft.SqlServer.Compact": "4.0.8876.1", "Microsoft.SqlServer.Compact": "4.0.8876.1",
"MySql.Data": "6.9.8",
"System.Data.SQLite.Core": "1.0.98.1", "System.Data.SQLite.Core": "1.0.98.1",
"xunit": "2.1.0" "xunit": "2.1.0"
} }
...@@ -92,6 +94,7 @@ ...@@ -92,6 +94,7 @@
}, },
"dependencies": { "dependencies": {
"Microsoft.SqlServer.Compact": "4.0.8876.1", "Microsoft.SqlServer.Compact": "4.0.8876.1",
"MySql.Data": "6.9.8",
"System.Data.SQLite.Core": "1.0.98.1", "System.Data.SQLite.Core": "1.0.98.1",
"xunit": "2.1.0", "xunit": "2.1.0",
"xunit.runner.dnx": "2.1.0-*" "xunit.runner.dnx": "2.1.0-*"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment