예제 #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
 public EntityDbContextDatabaseInitializer()
 {
     var dbContext = new EntityDbContext
     {
         Initializer = new DropCreateDatabaseIfModelChanges<EntityDbContext>()
     };
     dbContext.Initializer.InitializeDatabase(dbContext);
     var users = dbContext.Set<User>().ToArray();
     Assert.NotNull(users);
     users.Count().ShouldBeInRange(0, int.MaxValue);
     dbContext.Dispose();
 }
        public void InitializeDatabase_CustomizesDuringSeed_WhenDatabaseDoesNotExist()
        {
            using (var dbContext = new EntityDbContext())
            {
                dbContext.Database.Delete(); // force initializer to seed
                var dbCustomizer = new Mock<ICustomizeDb>(MockBehavior.Strict);
                dbCustomizer.Setup(x => x.Customize(It.IsAny<EntityDbContext>()));
                var dbInitializer = new GreenfieldDbInitializer(dbCustomizer.Object);
                dbContext.Initializer = dbInitializer;
                dbContext.Initializer.InitializeDatabase(dbContext);

                dbCustomizer.Verify(x => x.Customize(It.IsAny<EntityDbContext>()), Times.Once);
                dbContext.Dispose();
            }
        }
 public void Dispose()
 {
     _context?.Dispose();
 }
        public void Dispose()
        {
            _dbContext.Dispose();

            _sqliteConnection.Dispose();
        }