protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public TestContext Build() { var dbInitializer = new TestPhotosDbInitializer(_albums); Database.SetInitializer(dbInitializer); PhotosDbContext context = null; try { context = new PhotosDbContext(); context.Database.Initialize(force: true); return(new TestContext(context)); } catch (Exception) { context?.Dispose(); throw; } }