public ServiceProviderPerContextFixtureBase()
        {
            TestStore = TestStoreFactory.GetOrCreate(StoreName);

            // Setup database.
            var serviceProvider = SetupServices();

            TestStore.Initialize(serviceProvider, () => CreateContextFromServiceProvider(serviceProvider), c => Seed((TContext)c), Clean);
        }
        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);
        }
示例#3
0
            public DbContextOptions CreateOptions(
                Action <ModelBuilder> onModelCreating = null, object additionalModelCacheKey = null, bool seed = true)
            {
                OnModelCreatingAction   = onModelCreating;
                AdditionalModelCacheKey = additionalModelCacheKey;
                var options = CreateOptions(TestStore);

                TestStore.Initialize(ServiceProvider, () => new EmbeddedTransportationContext(options), c =>
                {
                    if (seed)
                    {
                        ((TransportationContext)c).Seed();
                    }
                });

                ListLoggerFactory.Clear();
                return(options);
            }
示例#4
0
 protected TestStore CreateTestStore()
 {
     TestStore = SqlServerTestStore.Create(nameof(MemoryOptimizedTablesTest));
     TestStore.Initialize(null, CreateContext, c => { });
     return(TestStore);
 }
示例#5
0
 public virtual Task InitializeAsync()
 {
     _testStore = NpgsqlTestStoreFactory.Instance.GetOrCreate(StoreName);
     _testStore.Initialize(null, CreateContext, c => CompatibilityContext.Seed((CompatibilityContext)c));
     return(Task.CompletedTask);
 }