public void TestCreateDatabase() { MedSimDbContext db = null; try { db = new MedSimDbContext(); Assert.IsTrue(db.Cultures.Any(), "MedSimDbContext accessed, but no cultures seeded"); } catch (DataException e) { var inner = e.InnerException as DbEntityValidationException; if (inner != null) { Debug.Write(string.Join("\r\n", inner.EntityValidationErrors.Select(i => string.Join(";", i.ValidationErrors.Select(v => v.ErrorMessage))))); } throw; } finally { if (db != null) { db.Dispose(); } } }
void Dispose(bool disposing) { // would be protected virtual if not sealed if (disposing && _context != null && _contextOwner) { // only run this logic when Dispose is called _context.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing) { if (_repo != null) { _repo.Dispose(); } _streamsToDispose.ForEach(s => s.Dispose()); } base.Dispose(disposing); }
public void TestCreateDatabase() { MedSimDbContext db = null; try { db = new MedSimDbContext(); Assert.IsTrue(db.Cultures.Any(), "MedSimDbContext accessed, but no cultures seeded"); } catch(DataException e) { var inner = e.InnerException as DbEntityValidationException; if (inner!=null) { Debug.Write(string.Join("\r\n", inner.EntityValidationErrors.Select(i=>string.Join(";",i.ValidationErrors.Select(v=>v.ErrorMessage))))); } throw; } finally { if (db!=null) db.Dispose(); } }