You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using EntityFrameworkCore.Jet.Data;
|
|
using System.IO;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace EntityFrameworkCore.Jet.IntegrationTests
|
|
{
|
|
[TestClass]
|
|
public class DatabaseHandlingTest
|
|
{
|
|
[TestMethod]
|
|
public void EnsureDeleted_Github21()
|
|
{
|
|
var storePath = DatabaseHandlingTestContext.GetStorePath();
|
|
|
|
File.Delete(storePath);
|
|
|
|
using (var ctx = new DatabaseHandlingTestContext())
|
|
{
|
|
ctx.Database.EnsureCreated();
|
|
}
|
|
|
|
Assert.IsTrue(File.Exists(storePath), "The db has not been created");
|
|
|
|
using (var ctx = new DatabaseHandlingTestContext())
|
|
{
|
|
ctx.Database.EnsureDeleted();
|
|
}
|
|
|
|
Assert.IsFalse(File.Exists(storePath), "The db has not been deleted");
|
|
}
|
|
|
|
public class DatabaseHandlingTestContext : DbContext
|
|
{
|
|
public static string GetStorePath() => Helpers.GetJetStorePath(nameof(DatabaseHandlingTest) + ".accdb");
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseJet(JetConnection.GetConnectionString(GetStorePath(), Helpers.DataAccessProviderFactory), Helpers.DataAccessProviderFactory);
|
|
}
|
|
}
|
|
}
|
|
} |