示例#1
0
        public static string FreshFromDump()
        {
            SetDbConnection("mysql", "localhost");           //Must connect to the mysql database so we can drop and recreate the test database.
            string command = "DROP DATABASE IF EXISTS canadatest";

            try{
                DataCore.NonQ(command);
            }
            catch {
                throw new Exception("Database could not be dropped.  Please remove any remaining text files and try again.");
            }
            command = "CREATE DATABASE canadatest";
            DataCore.NonQ(command);
            SetDbConnection("canadatest");
            command = Properties.Resources.dumpcanada;
            DataCore.NonQ(command);
            Cache.ClearAllCache();
            string toVersion = Assembly.GetAssembly(typeof(OpenDental.PrefL)).GetName().Version.ToString();

            //MessageBox.Show(Application.ProductVersion+" - "+
            if (!PrefL.ConvertDB(true, toVersion))
            {
                throw new Exception("Wrong version.");
            }
            ProcedureCodes.TcodesClear();
            AutoCodes.SetToDefaultCanada();
            Prefs.UpdateDateT(PrefName.BackupReminderLastDateRun, DateTime.MaxValue.AddYears(-1));           //We do not need backup reminders while testing.
            return("Fresh database loaded from sql dump.\r\n");
        }
示例#2
0
        public static string FreshFromDump(string serverAddr, string port, string userName, string password, bool isOracle)
        {
            Security.CurUser = Security.CurUser ?? new Userod();
            if (!isOracle)
            {
                string command = "DROP DATABASE IF EXISTS " + TestBase.UnitTestDbName;
                try {
                    DataCore.NonQ(command);
                }
                catch {
                    throw new Exception("Database could not be dropped.  Please remove any remaining text files and try again.");
                }
                command = "CREATE DATABASE " + TestBase.UnitTestDbName;
                DataCore.NonQ(command);
                UnitTestsCore.DatabaseTools.SetDbConnection(TestBase.UnitTestDbName, serverAddr, port, userName, password, false);
                command = Properties.Resources.dump;
                DataCore.NonQ(command);
                string toVersion = Assembly.GetAssembly(typeof(OpenDental.PrefL)).GetName().Version.ToString();
                //MessageBox.Show(Application.ProductVersion+" - "+
                if (!PrefL.ConvertDB(true, toVersion, null))
                {
                    throw new Exception("Wrong version.");
                }
                ProcedureCodes.TcodesClear();
                FormProcCodes.ImportProcCodes("", CDT.Class1.GetADAcodes(), "");              //IF THIS LINE CRASHES:
                //Go to Solution, Configuration Manager.  Exclude UnitTest project from build.
                AutoCodes.SetToDefault();
                ProcButtons.SetToDefault();
                ProcedureCodes.ResetApptProcsQuickAdd();
                //RefreshCache (might be missing a few)  Or, it might make more sense to do this as an entirely separate method when running.
                ProcedureCodes.RefreshCache();
                command = "UPDATE userod SET Password='******' WHERE UserNum=1";              //sets Password to 'pass' for middle tier testing.
                DataCore.NonQ(command);
                AddCdcrecCodes();
            }
            else
            {
                //This stopped working. Might look into it later: for now manually create the unittest db

                //Make sure the command CREATE OR REPLACE DIRECTORY dmpdir AS 'c:\oraclexe\app\tmp'; was run
                //and there is an opendental user with matching username/pass
                //The unittest.dmp was taken from a fresh unittest db created from the code above.  No need to alter it further.
                //string command=@"impdp opendental/opendental DIRECTORY=dmpdir DUMPFILE=unittest.dmp TABLE_EXISTS_ACTION=replace LOGFILE=impschema.log";
                //ExecuteCommand(command);
            }
            return("Fresh database loaded from sql dump.\r\n");
        }