Beispiel #1
0
            public override DbContext CreateContext(InMemoryTestStore testStore)
            {
                var optionsBuilder = new DbContextOptionsBuilder();

                optionsBuilder.UseInMemoryDatabase();

                var context = new StoreGeneratedContext(_serviceProvider, optionsBuilder.Options);

                return(context);
            }
Beispiel #2
0
            public override DbContext CreateContext(InMemoryTestStore testStore)
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseInMemoryDatabase()
                                     .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning))
                                     .UseInternalServiceProvider(_serviceProvider);

                var context = new StoreGeneratedContext(optionsBuilder.Options);

                return(context);
            }
Beispiel #3
0
            public override DbContext CreateContext(SqliteTestStore testStore)
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseSqlite(testStore.Connection)
                                     .UseInternalServiceProvider(_serviceProvider);

                var context = new StoreGeneratedContext(optionsBuilder.Options);

                context.Database.UseTransaction(testStore.Transaction);

                return(context);
            }
            public override DbContext CreateContext(SqliteTestStore testStore)
            {
                var optionsBuilder = new EntityOptionsBuilder();

                optionsBuilder.UseSqlite(testStore.Connection);

                var context = new StoreGeneratedContext(_serviceProvider, optionsBuilder.Options);

                context.Database.AsRelational().Connection.UseTransaction(testStore.Transaction);

                return(context);
            }
Beispiel #5
0
            public override DbContext CreateContext(NpgsqlTestStore testStore)
            {
                var optionsBuilder = new DbContextOptionsBuilder();

                optionsBuilder.UseNpgsql(testStore.Connection);

                var context = new StoreGeneratedContext(_serviceProvider, optionsBuilder.Options);

                context.Database.UseTransaction(testStore.Transaction);

                return(context);
            }
Beispiel #6
0
            public override SqliteTestStore CreateTestStore()
            {
                return(SqliteTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder()
                                         .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName))
                                         .UseInternalServiceProvider(_serviceProvider);

                    using (var context = new StoreGeneratedContext(optionsBuilder.Options))
                    {
                        context.Database.EnsureClean();
                    }
                }));
            }
Beispiel #7
0
            public override InMemoryTestStore CreateTestStore()
            {
                return(InMemoryTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder();
                    optionsBuilder.UseInMemoryDatabase();

                    using (var context = new StoreGeneratedContext(_serviceProvider, optionsBuilder.Options))
                    {
                        context.Database.EnsureDeleted();
                        context.Database.EnsureCreated();
                    }
                }));
            }
            public override SqliteTestStore CreateTestStore()
            {
                return(SqliteTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new EntityOptionsBuilder();
                    optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName));

                    using (var context = new StoreGeneratedContext(_serviceProvider, optionsBuilder.Options))
                    {
                        context.Database.EnsureDeleted();
                        context.Database.EnsureCreated();
                    }
                }));
            }
Beispiel #9
0
            public override InMemoryTestStore CreateTestStore()
            => InMemoryTestStore.GetOrCreateShared(DatabaseName, () =>
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseInMemoryDatabase()
                                     .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning))
                                     .UseInternalServiceProvider(_serviceProvider);

                using (var context = new StoreGeneratedContext(optionsBuilder.Options))
                {
                    context.Database.EnsureDeleted();
                    context.Database.EnsureCreated();
                }
            });