예제 #1
0
            public FindSqliteFixture()
            {
                var serviceProvider = new ServiceCollection()
                                      .AddEntityFrameworkSqlite()
                                      .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating))
                                      .BuildServiceProvider();

                _options = new DbContextOptionsBuilder()
                           .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName))
                           .UseInternalServiceProvider(serviceProvider)
                           .Options;
            }
예제 #2
0
            public override SqliteTestStore CreateTestStore()
            {
                return(SqliteTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder()
                                         .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName))
                                         .UseInternalServiceProvider(_serviceProvider);

                    using (var context = new StoreGeneratedContext(optionsBuilder.Options))
                    {
                        context.Database.EnsureClean();
                    }
                }));
            }
예제 #3
0
            public NotificationEntitiesSqliteFixture()
            {
                var serviceProvider = new ServiceCollection()
                                      .AddEntityFrameworkSqlite()
                                      .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating))
                                      .BuildServiceProvider();

                _options = new DbContextOptionsBuilder()
                           .UseSqlite(SqliteTestStore.CreateConnectionString("NotificationEntities"))
                           .UseInternalServiceProvider(serviceProvider)
                           .Options;

                EnsureCreated();
            }
예제 #4
0
            public NullKeysSqliteFixture()
            {
                var serviceProvider = new ServiceCollection()
                                      .AddEntityFrameworkSqlite()
                                      .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating))
                                      .BuildServiceProvider();

                _options = new DbContextOptionsBuilder()
                           .UseSqlite(SqliteTestStore.CreateConnectionString("StringsContext"))
                           .UseInternalServiceProvider(serviceProvider)
                           .Options;

                CreateContext().Database.EnsureClean();
                EnsureCreated();
            }
예제 #5
0
            public NullKeysSqliteFixture()
            {
                _serviceProvider = new ServiceCollection()
                                   .AddEntityFramework()
                                   .AddSqlite()
                                   .ServiceCollection()
                                   .AddSingleton(TestSqliteModelSource.GetFactory(OnModelCreating))
                                   .BuildServiceProvider();

                var optionsBuilder = new DbContextOptionsBuilder();

                optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString("StringsContext"));
                _options = optionsBuilder.Options;

                EnsureCreated();
            }
예제 #6
0
            public override SqliteTestStore CreateTestStore()
            {
                return(SqliteTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder();
                    optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName));

                    using (var context = new GraphUpdatesContext(_serviceProvider, optionsBuilder.Options))
                    {
                        context.Database.EnsureDeleted();
                        if (context.Database.EnsureCreated())
                        {
                            Seed(context);
                        }
                    }
                }));
            }
예제 #7
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);
            }
        }
예제 #8
0
 public override DbContext CreateContext()
 => new LoadContext(new DbContextOptionsBuilder()
                    .UseSqlite(SqliteTestStore.CreateConnectionString("LoadTest"))
                    .UseInternalServiceProvider(_serviceProvider)
                    .Options);
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseSqlite(SqliteTestStore.CreateConnectionString(_databaseName));
 }
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName))
 .UseInternalServiceProvider(_serviceProvider);