Esempio n. 1
0
        public override NpgsqlTestStore CreateTestStore()
        {
            return(NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseNpgsql(_connectionString, b => b.ApplyConfiguration())
                                     .UseInternalServiceProvider(_serviceProvider);

                using (var context = new InheritanceRelationshipsContext(optionsBuilder.Options))
                {
                    context.Database.EnsureCreated();
                    InheritanceRelationshipsModelInitializer.Seed(context);
                }
            }));
        }
Esempio n. 2
0
        public override SqliteTestStore CreateTestStore()
        => SqliteTestStore.GetOrCreateShared(
            nameof(InheritanceRelationshipsQuerySqliteTest),
            () =>
        {
            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseSqlite(SqliteTestStore.CreateConnectionString(nameof(InheritanceRelationshipsQuerySqliteTest)))
                                 .UseInternalServiceProvider(_serviceProvider);

            using (var context = new InheritanceRelationshipsContext(optionsBuilder.Options))
            {
                context.Database.EnsureClean();
                InheritanceRelationshipsModelInitializer.Seed(context);
            }
        });
Esempio n. 3
0
        public override SqlServerTestStore CreateTestStore()
        {
            return(SqlServerTestStore.GetOrCreateShared(DatabaseName, () =>
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseSqlServer(_connectionString)
                                     .UseInternalServiceProvider(_serviceProvider);

                using (var context = new InheritanceRelationshipsContext(optionsBuilder.Options))
                {
                    context.Database.EnsureClean();
                    InheritanceRelationshipsModelInitializer.Seed(context);

                    TestSqlLoggerFactory.Reset();
                }
            }));
        }
        public override SqliteTestStore CreateTestStore()
        => SqliteTestStore.GetOrCreateShared(
            nameof(InheritanceRelationshipsQuerySqliteTest),
            () =>
        {
            var optionsBuilder = new DbContextOptionsBuilder();
            optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString(nameof(InheritanceRelationshipsQuerySqliteTest)));

            using (var context = new InheritanceRelationshipsContext(_serviceProvider, optionsBuilder.Options))
            {
                // TODO: Delete DB if model changed
                context.Database.EnsureDeleted();
                if (context.Database.EnsureCreated())
                {
                    InheritanceRelationshipsModelInitializer.Seed(context);
                }

                TestSqlLoggerFactory.SqlStatements.Clear();
            }
        });
        public override NpgsqlTestStore CreateTestStore()
        {
            return(NpgsqlTestStore.GetOrCreateShared(DatabaseName, () =>
            {
                var optionsBuilder = new DbContextOptionsBuilder()
                                     .UseNpgsql(_connectionString)
                                     .UseInternalServiceProvider(_serviceProvider);

                using (var context = new InheritanceRelationshipsContext(optionsBuilder.Options))
                {
                    // TODO: Delete DB if model changed
                    context.Database.EnsureDeleted();
                    if (context.Database.EnsureCreated())
                    {
                        InheritanceRelationshipsModelInitializer.Seed(context);
                    }

                    TestSqlLoggerFactory.Reset();
                }
            }));
        }