public OneToOneQuerySqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlite() .ServiceCollection() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); _testStore = SqliteTestStore.CreateScratch(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlite(_testStore.ConnectionString); _options = optionsBuilder.Options; using (var context = new DbContext(_serviceProvider, _options)) { context.Database.EnsureCreated(); AddTestData(context); } }
public StoreGeneratedSqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); }
public InheritanceSqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlite() .ServiceCollection() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); _testStore = SqliteTestStore.CreateScratch(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlite(_testStore.Connection); _options = optionsBuilder.Options; // TODO: Do this via migrations & update pipeline _testStore.ExecuteNonQuery(@" DROP TABLE IF EXISTS Country; DROP TABLE IF EXISTS Animal; CREATE TABLE Country ( Id int NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL ); CREATE TABLE Animal ( Species nvarchar(100) NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL, CountryId int NOT NULL , IsFlightless bit NOT NULL, EagleId nvarchar(100), 'Group' int, FoundOn tinyint, Discriminator nvarchar(255), FOREIGN KEY(countryId) REFERENCES Country(Id), FOREIGN KEY(EagleId) REFERENCES Animal(Species) ); CREATE TABLE Plant ( Genus int NOT NULL, Species nvarchar(100) NOT NULL PRIMARY KEY, Name nvarchar(100) NOT NULL, CountryId int, HasThorns bit, FOREIGN KEY(countryId) REFERENCES Country(Id) ); "); using (var context = CreateContext()) { SeedData(context); } TestSqlLoggerFactory.Reset(); }
protected GraphUpdatesSqliteFixtureBase() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); }
public DataAnnotationSqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); }
public InheritanceRelationshipsQuerySqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); }
public ComplexNavigationsQuerySqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlite() .ServiceCollection() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); }
public override DbContextOptions BuildOptions(IServiceCollection additionalServices = null) => ConfigureOptions( new DbContextOptionsBuilder() .UseInternalServiceProvider((additionalServices ?? new ServiceCollection()) .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory) .BuildServiceProvider())) .UseSqlite( _testStore.ConnectionString, b => ConfigureOptions(b).SuppressForeignKeyEnforcement()) .Options;
public FindSqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName)) .UseInternalServiceProvider(serviceProvider) .Options; }
public GearsOfWarQuerySqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(_connectionString) .UseInternalServiceProvider(serviceProvider) .Options; }
public NorthwindQuerySqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory) .BuildServiceProvider(); _options = BuildOptions(); _serviceProvider.GetRequiredService <ILoggerFactory>(); }
public NotificationEntitiesSqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString("NotificationEntities")) .UseInternalServiceProvider(serviceProvider) .Options; EnsureCreated(); }
public NullKeysSqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString("StringsContext")) .UseInternalServiceProvider(serviceProvider) .Options; CreateContext().Database.EnsureClean(); EnsureCreated(); }
public NullKeysSqliteFixture() { _serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlite() .ServiceCollection() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString("StringsContext")); _options = optionsBuilder.Options; EnsureCreated(); }
public BuiltInDataTypesSqliteFixture() { _testStore = SqliteTestStore.CreateScratch(); var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(_testStore.Connection) .UseInternalServiceProvider(serviceProvider) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureCreated(); } }
public InheritanceSqliteFixture() { _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString("InheritanceSqlite")) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider()) .Options; using (var context = CreateContext()) { context.Database.EnsureClean(); SeedData(context); } TestSqlLoggerFactory.Reset(); }