Exemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this._disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     this._disposed = true;
 }
Exemplo n.º 2
0
        public static void ClassCleanup()
        {
            dbContext.Dispose();

            if (!dbCreated)
            {
                return;
            }

            var builder =
                new SqlConnectionStringBuilder(
                    System.Configuration.ConfigurationManager.ConnectionStrings["HealthCheckEntities"].ConnectionString);

            using (var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HealthCheckEntities"].ConnectionString))
            {
                conn.Open();
                var command = conn.CreateCommand();
                command.CommandText =
                    string.Format("use master; alter database {0} set single_user with rollback immediate; drop database {0}", builder.InitialCatalog);
                command.ExecuteNonQuery();
            }

            container = null;
        }