Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
 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();
     }
 }
Ejemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_repo != null)
         {
             _repo.Dispose();
         }
         _streamsToDispose.ForEach(s => s.Dispose());
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 4
0
        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();
            }
        }