public ComplexNavigationsQuerySpannerFixture() { _serviceProvider = new ServiceCollection() .AddEntityFrameworkSpanner() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseSpanner(_connectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider(_serviceProvider).Options; }
public GearsOfWarQuerySqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName)) .UseInternalServiceProvider(serviceProvider) .Options; }
public InheritanceSqlCeFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlCe() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseInternalServiceProvider(serviceProvider) .Options; }
public NullSemanticsQuerySqlServerFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseInternalServiceProvider(serviceProvider) .Options; }
public override DbContextOptions BuildOptions(IServiceCollection additionalServices = null) => ConfigureOptions( new DbContextOptionsBuilder() .UseInternalServiceProvider( (additionalServices ?? new ServiceCollection()) .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider())) .UseSqlite( _testStore.ConnectionString, b => ConfigureOptions(b).SuppressForeignKeyEnforcement()) .Options;
public NullKeysJetFixture() { var name = "StringsContext"; var connectionString = JetTestStore.CreateConnectionString(name); _options = new DbContextOptionsBuilder() .UseJet(connectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkJet() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider()) .Options; }
public GearsOfWarQueryInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestLoggerFactory()) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(DatabaseName) .UseInternalServiceProvider(serviceProvider) .Options; }
public GearsOfWarQueryInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); var optionsBuilder = new DbContextOptionsBuilder() .UseInMemoryDatabase() .UseInternalServiceProvider(serviceProvider); _options = optionsBuilder.Options; }
public BuiltInDataTypesInMemoryFixture() { _testStore = new InMemoryTestStore(); var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(nameof(BuiltInDataTypesInMemoryFixture)) .UseInternalServiceProvider(serviceProvider) .Options; }
public ComplexNavigationsOwnedQueryOracleFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkOracle() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseOracle(_connectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider(serviceProvider).Options; }
public InheritanceInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(DatabaseName) .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning)) .UseInternalServiceProvider(serviceProvider) .Options; }
public NullKeysInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(nameof(NullKeysInMemoryFixture)) .UseInternalServiceProvider(serviceProvider).Options; EnsureCreated(); }
public GearsOfWarQuerySpannerFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSpanner() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .ConfigureWarnings(w => w.Log(CoreEventId.IncludeIgnoredWarning)) .UseInternalServiceProvider(serviceProvider) .Options; }
public InheritanceInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _optionsBuilder.UseInMemoryDatabase().UseInternalServiceProvider(serviceProvider); using (var context = CreateContext()) { SeedData(context); } }
public LoadSqlServerFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory, TestSqlLoggerFactory>() .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlServer(SqlServerTestStore.CreateConnectionString(DatabaseName), b => b.ApplyConfiguration()) .UseInternalServiceProvider(serviceProvider) .EnableSensitiveDataLogging() .Options; }
protected TestStore CreateTestStore(Action <ModelBuilder> onModelCreating = null) { TestStore = TestStoreFactory.Create(DatabaseName); ServiceProvider = TestStoreFactory.AddProviderServices(new ServiceCollection()) .AddSingleton(TestModelSource.GetFactory(onModelCreating ?? (_ => { }))) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true); TestStore.Initialize(ServiceProvider, CreateContext, c => ((TransportationContext)c).Seed()); TestSqlLoggerFactory.Clear(); return(TestStore); }
public NullKeysSqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString("StringsContext")) .UseInternalServiceProvider(serviceProvider) .Options; CreateContext().Database.EnsureClean(); EnsureCreated(); }
public DataAnnotationInMemoryFixture() { _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(nameof(DataAnnotationInMemoryFixture)) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider()) .ConfigureWarnings(w => { w.Default(WarningBehavior.Throw); w.Ignore(InMemoryEventId.TransactionIgnoredWarning); }) .Options; }
public NullKeysNpgsqlFixture() { var name = "StringsContext"; var connectionString = NpgsqlTestStore.CreateConnectionString(name); _options = new DbContextOptionsBuilder() .UseNpgsql(connectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkNpgsql() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider()) .Options; _testStore = NpgsqlTestStore.GetOrCreateShared(name, EnsureCreated); }
public OneToOneQueryInMemoryFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(validateScopes: true); _options = new DbContextOptionsBuilder() .UseInMemoryDatabase(nameof(OneToOneQueryInMemoryFixture)) .UseInternalServiceProvider(serviceProvider).Options; using (var context = new DbContext(_options)) { AddTestData(context); } }
public override DbContextOptions BuildOptions(IServiceCollection additionalServices = null) => ConfigureOptions( new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseInternalServiceProvider((additionalServices ?? new ServiceCollection()) .AddEntityFrameworkJet() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider())) .UseJet( _testStore.ConnectionString, b => { ConfigureOptions(b); b.ApplyConfiguration(); }).Options;
public InheritanceSqliteFixture() { _options = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString("InheritanceSqlite")) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider()) .Options; using (var context = CreateContext()) { context.Database.EnsureClean(); SeedData(context); } }
public DataAnnotationSqlServerFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() .UseInternalServiceProvider(serviceProvider) .ConfigureWarnings(w => { w.Default(WarningBehavior.Throw); w.Ignore(CoreEventId.SensitiveDataLoggingEnabledWarning); }).Options; }
protected InfoCarrierBackendTestStore( string name, bool shared, SharedTestStoreProperties testStoreProperties) : base(name, shared) { this.testStoreProperties = testStoreProperties; this.ServiceProvider = this.AddServices(new ServiceCollection()) .AddInfoCarrierServer() .AddSingleton <IInfoCarrierValueMapper, InfoCarrierNetTopologySuiteValueMapper>() .AddSingleton(TestModelSource.GetFactory(this.testStoreProperties.OnModelCreating)) .AddDbContext( this.testStoreProperties.ContextType, (s, b) => this.AddProviderOptions(b), ServiceLifetime.Transient, ServiceLifetime.Singleton) .BuildServiceProvider(); this.infoCarrierServer = this.ServiceProvider.GetRequiredService <IInfoCarrierServer>(); }
public BuiltInDataTypesSqliteFixture() { _testStore = SqliteTestStore.CreateScratch(); var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseSqlite(_testStore.Connection) .UseInternalServiceProvider(serviceProvider) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureClean(); } }
public OneToOneQuerySqlServerFixture() { _testStore = SqlServerTestStore.Create("OneToOneQueryTest"); _options = new DbContextOptionsBuilder() .UseSqlServer(_testStore.ConnectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkSqlServer() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider()) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureCreated(); AddTestData(context); } }
public OneToOneQueryNpgsqlFixture() { _testStore = NpgsqlTestStore.CreateScratch(); _options = new DbContextOptionsBuilder() .UseNpgsql(_testStore.ConnectionString) .UseInternalServiceProvider(new ServiceCollection() .AddEntityFrameworkNpgsql() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory()) .BuildServiceProvider()) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureCreated(); AddTestData(context); } }
public OwnedQueryOracleFixture() { _testStore = OracleTestStore.Create("OwnedQueryTest"); _options = new DbContextOptionsBuilder() .UseOracle(_testStore.ConnectionString, b => b.ApplyConfiguration()) .UseInternalServiceProvider( new ServiceCollection() .AddEntityFrameworkOracle() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true)) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureCreated(); AddTestData(context); } }
public BuiltInDataTypesNpgsqlFixture() { _testStore = NpgsqlTestStore.Create("BuiltInDataTypes"); var serviceProvider = new ServiceCollection() .AddEntityFrameworkNpgsql() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory) .BuildServiceProvider(); _options = new DbContextOptionsBuilder() .UseNpgsql(_testStore.Connection, b => b.ApplyConfiguration()) .EnableSensitiveDataLogging() .UseInternalServiceProvider(serviceProvider) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureCreated(); } }
public OneToOneQuerySqliteFixture() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddSingleton(TestModelSource.GetFactory(OnModelCreating)) .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory) .BuildServiceProvider(); _testStore = SqliteTestStore.CreateScratch(); _options = new DbContextOptionsBuilder() .UseSqlite(_testStore.ConnectionString) .UseInternalServiceProvider(serviceProvider) .Options; using (var context = new DbContext(_options)) { context.Database.EnsureClean(); AddTestData(context); } }