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.
EntityFrameworkCore.Jet/test/EFCore.Jet.FunctionalTests/OneToOneQueryJetFixture.cs

47 lines
1.5 KiB
C#

using EntityFramework.Jet.FunctionalTests.TestUtilities;
using EntityFrameworkCore.Jet;
using Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace EntityFramework.Jet.FunctionalTests
{
public class OneToOneQueryJetFixture : OneToOneQueryFixtureBase
{
private readonly DbContextOptions _options;
private readonly JetTestStore _testStore;
public TestSqlLoggerFactory TestSqlLoggerFactory { get; } = new TestSqlLoggerFactory();
public OneToOneQueryJetFixture()
{
_testStore = JetTestStore.CreateScratch(true);
_options = new DbContextOptionsBuilder()
.UseJet(_testStore.ConnectionString, b => b.ApplyConfiguration())
.UseInternalServiceProvider(new ServiceCollection()
.AddEntityFrameworkJet()
.AddSingleton(TestModelSource.GetFactory(OnModelCreating))
.AddSingleton<ILoggerFactory>(TestSqlLoggerFactory)
.BuildServiceProvider())
.Options;
using (var context = new DbContext(_options))
{
context.Database.EnsureCreated();
AddTestData(context);
}
}
public DbContext CreateContext()
{
return new DbContext(_options);
}
public void Dispose() => _testStore.Dispose();
}
}