Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public InheritanceSqlCeFixture()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlCe()
                                  .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                  .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory)
                                  .BuildServiceProvider(validateScopes: true);

            _options = new DbContextOptionsBuilder()
                       .EnableSensitiveDataLogging()
                       .UseInternalServiceProvider(serviceProvider)
                       .Options;
        }
Exemplo n.º 4
0
        public NullSemanticsQuerySqlServerFixture()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                  .AddSingleton <ILoggerFactory>(TestSqlLoggerFactory)
                                  .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .EnableSensitiveDataLogging()
                       .UseInternalServiceProvider(serviceProvider)
                       .Options;
        }
Exemplo n.º 5
0
 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;
            }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        public GearsOfWarQueryInMemoryFixture()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                  .BuildServiceProvider();

            var optionsBuilder = new DbContextOptionsBuilder()
                                 .UseInMemoryDatabase()
                                 .UseInternalServiceProvider(serviceProvider);

            _options = optionsBuilder.Options;
        }
Exemplo n.º 9
0
        public BuiltInDataTypesInMemoryFixture()
        {
            _testStore = new InMemoryTestStore();
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                  .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .UseInMemoryDatabase(nameof(BuiltInDataTypesInMemoryFixture))
                       .UseInternalServiceProvider(serviceProvider)
                       .Options;
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
            public NullKeysInMemoryFixture()
            {
                var serviceProvider = new ServiceCollection()
                                      .AddEntityFrameworkInMemoryDatabase()
                                      .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                      .BuildServiceProvider(validateScopes: true);

                _options = new DbContextOptionsBuilder()
                           .UseInMemoryDatabase(nameof(NullKeysInMemoryFixture))
                           .UseInternalServiceProvider(serviceProvider).Options;

                EnsureCreated();
            }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 15
0
            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);
        }
Exemplo n.º 17
0
            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();
            }
Exemplo n.º 18
0
 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);
            }
        }
Exemplo n.º 21
0
 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;
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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;
        }
Exemplo n.º 24
0
 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();
            }
        }
Exemplo n.º 26
0
        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);
            }
        }
Exemplo n.º 28
0
        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();
            }
        }
Exemplo n.º 30
0
        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);
            }
        }