コード例 #1
0
        public override CrossStoreContext CreateContext(TestStore testStore)
        {
            var inMemoryTestStore = testStore as InMemoryTestStore;

            if (inMemoryTestStore != null)
            {
                var optionsBuilder = new DbContextOptionsBuilder();
                optionsBuilder.UseInMemoryDatabase();

                return(new CrossStoreContext(_serviceProvider, optionsBuilder.Options));
            }

            var sqliteTestStore = testStore as SqliteTestStore;

            if (sqliteTestStore != null)
            {
                var optionsBuilder = new DbContextOptionsBuilder();
                optionsBuilder.UseSqlite(sqliteTestStore.Connection);

                var context = new CrossStoreContext(_serviceProvider, optionsBuilder.Options);
                context.Database.EnsureCreated();
                context.Database.UseTransaction(sqliteTestStore.Transaction);

                return(context);
            }

            var sqlServerTestStore = testStore as SqlServerTestStore;

            if (sqlServerTestStore != null)
            {
                var optionsBuilder = new DbContextOptionsBuilder();
                optionsBuilder.UseSqlServer(sqlServerTestStore.Connection);

                var context = new CrossStoreContext(_serviceProvider, optionsBuilder.Options);
                context.Database.EnsureCreated();
                context.Database.UseTransaction(sqlServerTestStore.Transaction);

                return(context);
            }

            throw new NotImplementedException();
        }
コード例 #2
0
 public override CrossStoreContext CreateContext(TestStore testStore)
 {
     return(_sharedCrossStoreFixture.CreateContext(testStore));
 }
コード例 #3
0
 public abstract CrossStoreContext CreateContext(TestStore testStore);
コード例 #4
0
 public void Dispose()
 {
     TestStore.Dispose();
 }
コード例 #5
0
 public void Dispose() => TestStore.Dispose();