示例#1
0
 public static EntityApp ActivateApp(EntityApp app, bool updateSchema = true, bool dropUnknownTables = false)
 {
     DeleteLocalLogFiles();
     app.LogPath       = LogFilePath;
     app.SystemLogPath = SystemLogFilePath;
     //If driver is not set, it means we are running from Test Explorer in VS. Use ServerTypeForTestExplorer
     if (Driver == null)
     {
         SetupForTestExplorerMode();
     }
     try {
         app.Init();
         var upgradeMode    = updateSchema ? DbUpgradeMode.Always : DbUpgradeMode.Never;
         var upgradeOptions = DbUpgradeOptions.Default;
         if (dropUnknownTables)
         {
             upgradeOptions |= DbUpgradeOptions.DropUnknownObjects;
         }
         var dbSettings = new DbSettings(Driver, DbOptions, ConnectionString, upgradeMode: upgradeMode, upgradeOptions: upgradeOptions);
         app.ConnectTo(dbSettings);
         return(app);
     } catch (StartupFailureException sx) {
         //Unit test framework shows only ex message, not details; let's write specifics into debug output - it will be shown in test failure report
         Debug.WriteLine("EntityApp init exception: ");
         Debug.WriteLine(sx.Log);
         throw;
     }
 }
示例#2
0
文件: _Startup.cs 项目: radtek/vita
        public static EntityApp ActivateApp(EntityApp app, bool dropOldSchema = true, bool dropOldTables = false)
        {
            //If driver is not set, it means we are running from Test Explorer in VS. Use ServerTypeForTestExplorer
            if (Driver == null)
            {
                SetupForTestExplorerMode();
            }
            app.LogPath           = LogFilePath;
            app.ActivationLogPath = ActivationLogPath;
            try {
                //Setup emitter
                app.EntityClassProvider = Vita.Entities.Emit.EntityClassEmitter.CreateEntityClassProvider();
                app.Init();

                var upgradeMode    = DbUpgradeMode.Always;
                var upgradeOptions = DbUpgradeOptions.Default;
                if (dropOldTables)
                {
                    upgradeOptions |= DbUpgradeOptions.DropUnknownObjects;
                }
                var dbSettings = new DbSettings(Driver, DbOptions, ConnectionString, upgradeMode: upgradeMode, upgradeOptions: upgradeOptions);

                // Drop schema/ delete all
                if (dropOldSchema)
                {
                    DropSchemaObjects(app, dbSettings);
                }
                app.ConnectTo(dbSettings);
                if (!dropOldSchema)
                {
                    DeleteAll(app);
                }
                return(app);
            } catch (StartupFailureException sx) {
                //Unit test framework shows only ex message, not details; let's write specifics into debug output - it will be shown in test failure report
                app.ActivationLog.Error(sx.Message);
                app.ActivationLog.Info(sx.Log);
                Debug.WriteLine("EntityApp init exception: ");
                Debug.WriteLine(sx.Log);
                throw;
            }
        }
示例#3
0
        // This test requies its own activation process, complications with drop schema and renaming tables - especially in Oracle

        private EntityApp SpecialActivateApp(EntityApp app, DbSettings dbSettings, bool dropOldSchema)
        {
            app.LogPath           = Startup.LogFilePath;
            app.ActivationLogPath = Startup.ActivationLogPath;
            try {
                //Setup emitter
                app.Init();
                if (dropOldSchema)
                {
                    Startup.DropSchemaObjects(app, dbSettings);
                }

                app.ConnectTo(dbSettings);
                return(app);
            } catch (Exception ex) {
                //Unit test framework shows only ex message, not details; let's write specifics into debug output - it will be shown in test failure report
                var descr = ex.ToLogString();
                app.ActivationLog.LogError(descr);
                Debug.WriteLine("EntityApp init exception: ");
                Debug.WriteLine(descr);
                throw;
            }
        }
示例#4
0
 public static EntityApp ActivateApp(EntityApp app, bool updateSchema = true, bool dropUnknownTables = false)
 {
     DeleteLocalLogFile();
       app.LogPath = LogFilePath;
       //If driver is not set, it means we are running from Test Explorer in VS. Use ServerTypeForTestExplorer
       if(Driver == null)
     SetupForTestExplorerMode();
       try {
     app.Init();
     var upgradeMode = updateSchema ? DbUpgradeMode.Always : DbUpgradeMode.Never;
     var upgradeOptions = DbUpgradeOptions.Default;
     if(dropUnknownTables)
       upgradeOptions |= DbUpgradeOptions.DropUnknownObjects;
     var dbSettings = new DbSettings(Driver, DbOptions, ConnectionString, upgradeMode: upgradeMode, upgradeOptions: upgradeOptions);
     app.ConnectTo(dbSettings);
     return app;
       } catch (StartupFailureException sx) {
     //Unit test framework shows only ex message, not details; let's write specifics into debug output - it will be shown in test failure report
     Debug.WriteLine("EntityApp init exception: ");
     Debug.WriteLine(sx.Log);
     throw;
       }
 }