Beispiel #1
0
 public StoreGeneratedNpgsqlFixture()
 {
     _serviceProvider = new ServiceCollection()
                        .AddEntityFramework()
                        .AddNpgsql()
                        .ServiceCollection()
                        .AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
                        .BuildServiceProvider();
 }
Beispiel #2
0
        public NorthwindQueryNpgsqlFixture()
        {
            _testStore = NpgsqlNorthwindContext.GetSharedStore();

            _serviceProvider = new ServiceCollection()
                               .AddEntityFramework()
                               .AddNpgsql()
                               .ServiceCollection()
                               .AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
                               .AddInstance <ILoggerFactory>(new TestSqlLoggerFactory())
                               .BuildServiceProvider();

            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseNpgsql(_testStore.Connection.ConnectionString);
            _options = optionsBuilder.Options;

            _serviceProvider.GetRequiredService <ILoggerFactory>()
            .MinimumLevel = LogLevel.Debug;
        }
        public BuiltInDataTypesNpgsqlFixture()
        {
            _testStore = NpgsqlTestStore.CreateScratch();

            _serviceProvider = new ServiceCollection()
                               .AddEntityFramework()
                               .AddNpgsql()
                               .ServiceCollection()
                               .AddSingleton(TestNpgsqlModelSource.GetFactory(OnModelCreating))
                               .BuildServiceProvider();

            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseNpgsql(_testStore.Connection);

            _options = optionsBuilder.Options;

            using (var context = new DbContext(_serviceProvider, _options))
            {
                context.Database.EnsureCreated();
            }
        }