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.
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System;
|
|
using System.Data.Common;
|
|
using EntityFrameworkCore.Jet;
|
|
using Extensions.DependencyInjection;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace EntityFramework.Jet.FunctionalTests
|
|
{
|
|
public class TransactionJetFixture : TransactionFixtureBase<JetTestStore>
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
public TransactionJetFixture()
|
|
{
|
|
_serviceProvider = new ServiceCollection()
|
|
.AddEntityFrameworkJet()
|
|
.AddSingleton(TestModelSource.GetFactory(OnModelCreating))
|
|
.BuildServiceProvider();
|
|
}
|
|
|
|
public override JetTestStore CreateTestStore()
|
|
{
|
|
var db = JetTestStore.CreateScratch(createDatabase: true);
|
|
|
|
using (var context = CreateContext(db))
|
|
{
|
|
context.Database.EnsureClean();
|
|
}
|
|
|
|
return db;
|
|
}
|
|
|
|
public override DbContext CreateContext(JetTestStore testStore)
|
|
{
|
|
var optionsBuilder = new DbContextOptionsBuilder();
|
|
optionsBuilder
|
|
.UseJet(testStore.Connection.ConnectionString)
|
|
.UseInternalServiceProvider(_serviceProvider);
|
|
|
|
return new DbContext(optionsBuilder.Options);
|
|
}
|
|
|
|
public override DbContext CreateContext(DbConnection connection)
|
|
{
|
|
var optionsBuilder = new DbContextOptionsBuilder();
|
|
optionsBuilder
|
|
.UseJet(connection)
|
|
.UseInternalServiceProvider(_serviceProvider);
|
|
|
|
return new DbContext(optionsBuilder.Options);
|
|
}
|
|
}
|
|
}
|