示例#1
0
 public override InMemoryTestStore CreateTestStore()
 => InMemoryTestStore.CreateScratch(
     () =>
 {
     using (var context = new UpdatesContext(_optionsBuilder.Options))
     {
         UpdatesModelInitializer.Seed(context);
     }
 },
     () => { _serviceProvider.GetRequiredService <IInMemoryStore>().Clear(); });
示例#2
0
 public override InMemoryTestStore CreateTestStore()
 => InMemoryTestStore.CreateScratch(
     () =>
 {
     using (var context = new UpdatesContext(_optionsBuilder.Options))
     {
         UpdatesModelInitializer.Seed(context);
     }
 },
     _serviceProvider);
        public override NpgsqlTestStore CreateTestStore()
        => NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseNpgsql(NpgsqlTestStore.CreateConnectionString(DatabaseName), b => b.ApplyConfiguration())
                                 .UseInternalServiceProvider(_serviceProvider);

            using (var context = new UpdatesContext(optionsBuilder.Options))
            {
                context.Database.EnsureCreated();
                UpdatesModelInitializer.Seed(context);
            }
        });
示例#4
0
 public override SqliteTestStore CreateTestStore() =>
 SqliteTestStore.GetOrCreateShared(
     DatabaseName,
     () =>
 {
     using (var context = new UpdatesContext(new DbContextOptionsBuilder()
                                             .UseSqlite(_connectionString)
                                             .UseInternalServiceProvider(_serviceProvider).Options))
     {
         context.Database.EnsureClean();
         UpdatesModelInitializer.Seed(context);
     }
 });
示例#5
0
        public override SqlServerTestStore CreateTestStore()
        {
            return(SqlServerTestStore.GetOrCreateShared(DatabaseName, () =>
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseSqlServer(SqlServerTestStore.CreateConnectionString(DatabaseName))
                                     .UseInternalServiceProvider(_serviceProvider);

                using (var context = new UpdatesContext(optionsBuilder.Options))
                {
                    context.Database.EnsureClean();
                    UpdatesModelInitializer.Seed(context);
                }
            }));
        }
        public override SqliteTestStore CreateTestStore() =>
        SqliteTestStore.GetOrCreateShared(
            DatabaseName,
            () =>
        {
            using (var context = new UpdatesContext(new DbContextOptionsBuilder()
                                                    .UseSqlite(_connectionString)
                                                    .UseInternalServiceProvider(_serviceProvider).Options))
            {
                // TODO: Delete DB if model changed
                context.Database.EnsureDeleted();
                if (context.Database.EnsureCreated())
                {
                    UpdatesModelInitializer.Seed(context);
                }

                TestSqlLoggerFactory.Reset();
            }
        });