protected override void CreateAndSeedDatabase(string databaseName, Func <MonsterContext> createContext, Action <MonsterContext> seed)
 {
     _testStore = SqlCeTestStore.GetOrCreateShared(databaseName, () =>
     {
         using (var context = createContext())
         {
             context.Database.EnsureCreated();
             seed(context);
         }
     });
 }
 public override SqlCeTestStore CreateTestStore()
 {
     return(SqlCeTestStore.GetOrCreateShared(DatabaseName, () =>
     {
         using (var context = new FindContext(_options))
         {
             context.Database.EnsureClean();
             Seed(context);
         }
     }));
 }
Exemplo n.º 3
0
            public NullKeysSqlCeFixture()
            {
                var name             = "StringsContext";
                var connectionString = SqlCeTestStore.CreateConnectionString(name);

                _options = new DbContextOptionsBuilder()
                           .UseSqlCe(connectionString, b => b.ApplyConfiguration())
                           .UseInternalServiceProvider(new ServiceCollection()
                                                       .AddEntityFrameworkSqlCe()
                                                       .AddSingleton(TestModelSource.GetFactory(OnModelCreating))
                                                       .BuildServiceProvider())
                           .Options;

                _testStore = SqlCeTestStore.GetOrCreateShared(name, EnsureCreated);
            }
            public override SqlCeTestStore CreateTestStore()
            {
                return(SqlCeTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder()
                                         .UseSqlCe(SqlCeTestStore.CreateConnectionString(DatabaseName))
                                         .UseInternalServiceProvider(_serviceProvider);

                    using (var context = new AdvancedPatternsMasterContext(optionsBuilder.Options))
                    {
                        context.Database.EnsureClean();
                        Seed(context);
                    }
                }));
            }
            public override SqlCeTestStore CreateTestStore()
            {
                return(SqlCeTestStore.GetOrCreateShared(DatabaseName, () =>
                {
                    var optionsBuilder = new DbContextOptionsBuilder()
                                         .UseSqlCe(SqlCeTestStore.CreateConnectionString(DatabaseName), b => b.ApplyConfiguration())
                                         .UseInternalServiceProvider(_serviceProvider);

                    using (var context = new FieldMappingContext(optionsBuilder.Options))
                    {
                        context.Database.EnsureClean();
                        Seed(context);
                    }
                }));
            }
Exemplo n.º 6
0
 public static SqlCeTestStore GetNorthwindStore()
 => SqlCeTestStore.GetOrCreateShared(NorthwindName, () => { });
Exemplo n.º 7
0
 public override SqlCeTestStore CreateTestStore()
 => SqlCeTestStore.GetOrCreateShared(DatabaseName, EnsureCreated);