protected TestStore CreateTestStore(Action <ModelBuilder> onModelCreating) { TestStore = TestStoreFactory.Create(DatabaseName); ServiceProvider = TestStoreFactory.AddProviderServices(new ServiceCollection()) .AddSingleton(TestModelSource.GetFactory(onModelCreating)) .BuildServiceProvider(validateScopes: true); TestStore.Initialize(ServiceProvider, CreateContext, c => ((TransportationContext)c).Seed()); return(TestStore); }
protected SharedStoreFixtureBase() { TestStore = TestStoreFactory.GetOrCreate(StoreName); var services = AddServices(TestStoreFactory.AddProviderServices(new ServiceCollection())); if (UsePooling) { services = services.AddDbContextPool(ContextType, (s, b) => ConfigureOptions(s, b)); } else { services = services.AddDbContext( ContextType, (s, b) => ConfigureOptions(s, b), ServiceLifetime.Transient, ServiceLifetime.Singleton); } ServiceProvider = services.BuildServiceProvider(validateScopes: true); TestStore.Initialize(ServiceProvider, CreateContext, c => Seed((TContext)c), c => Clean(c)); }