|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Data.Odbc;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
@ -25,31 +26,67 @@ namespace EntityFrameworkCore.Jet.Data.Tests
|
|
|
|
|
public void CreateAndDropDatabaseFromConnection()
|
|
|
|
|
{
|
|
|
|
|
using var connection = new JetConnection(StoreName, Helpers.DataAccessProviderFactory);
|
|
|
|
|
|
|
|
|
|
connection.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(File.Exists(StoreName));
|
|
|
|
|
|
|
|
|
|
using var command = connection.CreateCommand();
|
|
|
|
|
command.CommandText = "DROP DATABASE " + StoreName;
|
|
|
|
|
command.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connection.DropDatabase();
|
|
|
|
|
Assert.IsFalse(File.Exists(StoreName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CreateAndDropDatabaseWithUnsetConnection()
|
|
|
|
|
{
|
|
|
|
|
using var connection = new JetConnection();
|
|
|
|
|
using var connection = new JetConnection(Helpers.DataAccessProviderFactory);
|
|
|
|
|
|
|
|
|
|
var command = connection.CreateCommand();
|
|
|
|
|
command.CommandText = "CREATE DATABASE " + StoreName;
|
|
|
|
|
command.CommandText = $"CREATE DATABASE '{StoreName}'";
|
|
|
|
|
command.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(File.Exists(StoreName));
|
|
|
|
|
|
|
|
|
|
command.CommandText = "DROP DATABASE " + StoreName;
|
|
|
|
|
command.CommandText = $"DROP DATABASE '{StoreName}'";
|
|
|
|
|
command.ExecuteNonQuery();
|
|
|
|
|
Assert.IsFalse(File.Exists(StoreName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CreateAndDropDatabaseWithUnsetConnectionWithoutDataAccessProviderFactoryThrows()
|
|
|
|
|
{
|
|
|
|
|
using var connection = new JetConnection();
|
|
|
|
|
|
|
|
|
|
Assert.ThrowsException<InvalidOperationException>(
|
|
|
|
|
() => { using var command = connection.CreateCommand(); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CreateAndDropDatabaseWithSingleQuotedConnectionString()
|
|
|
|
|
{
|
|
|
|
|
var connectionString = Helpers.DataAccessProviderFactory is OdbcFactory
|
|
|
|
|
? $"DBQ='{StoreName}'"
|
|
|
|
|
: $"Data Source='{StoreName}'";
|
|
|
|
|
|
|
|
|
|
using var connection = new JetConnection(connectionString, Helpers.DataAccessProviderFactory);
|
|
|
|
|
|
|
|
|
|
connection.CreateDatabase();
|
|
|
|
|
Assert.IsTrue(File.Exists(StoreName));
|
|
|
|
|
|
|
|
|
|
connection.DropDatabase();
|
|
|
|
|
Assert.IsFalse(File.Exists(StoreName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CreateAndDropDatabaseWithDoubleQuotedConnectionString()
|
|
|
|
|
{
|
|
|
|
|
var connectionString = Helpers.DataAccessProviderFactory is OdbcFactory
|
|
|
|
|
? $"DBQ=\"{StoreName}\""
|
|
|
|
|
: $"Data Source=\"{StoreName}\"";
|
|
|
|
|
|
|
|
|
|
using var connection = new JetConnection(connectionString, Helpers.DataAccessProviderFactory);
|
|
|
|
|
|
|
|
|
|
connection.CreateDatabase();
|
|
|
|
|
Assert.IsTrue(File.Exists(StoreName));
|
|
|
|
|
|
|
|
|
|
connection.DropDatabase();
|
|
|
|
|
Assert.IsFalse(File.Exists(StoreName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|