Example #1
0
 private void butNewDb_Click(object sender, EventArgs e)
 {
     textResults.Text = "";
     Application.DoEvents();
     Cursor = Cursors.WaitCursor;
     if (!_isOracle)
     {
         string serverAddr = textAddr.Text;
         string serverPort = textPort.Text;
         if (serverAddr == "")
         {
             serverAddr = "localhost";
         }
         if (serverPort == "")
         {
             serverPort = "3306";
         }
         if (!UnitTestsCore.DatabaseTools.SetDbConnection("", serverAddr, serverPort, textUserName.Text, textPassword.Text, _isOracle))
         {
             OpenDental.MessageBox.Show("Could not connect");
             return;
         }
     }
     DatabaseTools.FreshFromDump(textAddr.Text, textPort.Text, textUserName.Text, textPassword.Text, _isOracle);
     textResults.Text += "Fresh database loaded from sql dump.";
     Cursor            = Cursors.Default;
 }
Example #2
0
        public void Initialize()
        {
            //Create test DB
            DatabaseTools.SetDbConnection("", "localhost", "3306", "root", "", false);
            DatabaseTools.FreshFromDump("localhost", "3306", "root", "", false);
            //Inject data
            var seedData = File.ReadAllText(@"..\..\Resources\backlogrecall.txt");

            DatabaseTools.ExecuteSqlScript("localhost", "3306", "root", "", seedData);
        }
Example #3
0
 private void butNewDb_Click(object sender, EventArgs e)
 {
     textResults.Text = "";
     Application.DoEvents();
     Cursor = Cursors.WaitCursor;
     if (!isOracle)
     {
         if (!DatabaseTools.SetDbConnection("", isOracle))
         {
             MessageBox.Show("Could not connect");
             return;
         }
     }
     DatabaseTools.FreshFromDump(isOracle);
     textResults.Text += "Fresh database loaded from sql dump.";
     Cursor            = Cursors.Default;
 }
Example #4
0
 private void butHL7_Click(object sender, EventArgs e)
 {
     textResults.Text = "";
     Application.DoEvents();
     Cursor = Cursors.WaitCursor;
     if (!DatabaseTools.SetDbConnection("unittest", false))            //if database doesn't exist
     {
         DatabaseTools.SetDbConnection("", false);
         textResults.Text += DatabaseTools.FreshFromDump(false);              //this also sets database to be unittest.
     }
     foreach (HL7TestInterfaceEnum hl7TestInterfaceEnum in Enum.GetValues(typeof(HL7TestInterfaceEnum)))
     {
         textResults.Text += DatabaseTools.ClearDb();
         textResults.Text += "Testing " + hl7TestInterfaceEnum.ToString() + " interface.\r\n";
         textResults.Text += HL7Tests.HL7TestAll(hl7TestInterfaceEnum);
         textResults.Text += "\r\n\r\n";
     }
     textResults.Text += "Done\r\n";
     Cursor            = Cursors.Default;
 }
Example #5
0
 public static void Initialize(TestContext context)
 {
     ODInitialize.IsRunningInUnitTest = true;                                                                  //Causes FormFriendlyException to throw rather than displaying a MessageBox.
     ODInitialize.Initialize();
     if (!UnitTestsCore.DatabaseTools.SetDbConnection(UnitTestDbName, "localhost", "3306", "root", "", false)) //Put this in a config file in the future.
     {
         UnitTestsCore.DatabaseTools.SetDbConnection("", "localhost", "3306", "root", "", false);
         DatabaseTools.FreshFromDump("localhost", "3306", "root", "", false);            //this also sets database to be unittest.
     }
     else
     {
         //Clear the database before running the unittests (instead of after) for two reasons
         //1- if the cleanup is done using [TestCleanup], the cleanup will not be run if the user cancels in the middle of a test while debugging
         //2- if a test fails, we may want to look at the data in the db to see why it failed.
         UnitTestsCore.DatabaseTools.ClearDb();
     }
     if (!ODBuild.IsDebug())
     {
         throw new Exception("Active solution configuration must be set to Debug for running unit tests.");
     }
     CreateAndSetUnitTestUser();
     RevertMiddleTierSettingsIfNeeded();            //Set initial connection
 }
Example #6
0
        public static void Initialize(TestContext context)
        {
            if (!UnitTestsCore.DatabaseTools.SetDbConnection("unittest", "localhost", "3306", "root", "", false))        //Put this in a config file in the future.
            {
                UnitTestsCore.DatabaseTools.SetDbConnection("", "localhost", "3306", "root", "", false);
                DatabaseTools.FreshFromDump("localhost", "3306", "root", "", false);            //this also sets database to be unittest.
            }
            else
            {
                //Clear the database before running the unittests (instead of after) for two reasons
                //1- if the cleanup is done using [TestCleanup], the cleanup will not be run if the user cancels in the middle of a test while debugging
                //2- if a test fails, we may want to look at the data in the db to see why it failed.
                UnitTestsCore.DatabaseTools.ClearDb();
            }
#if !DEBUG
            throw new Exception("You're running tests in release. BAD!!!");
#endif
            CreateUnitTestUser();
            //Get the Admin user, should always exist
            Security.CurUser       = Userods.GetUserByName(UnitTestUserName, false);
            Security.PasswordTyped = UnitTestPassword;          //For middle tier unit tests.
            //Uncomment the next line in order to run every single unit test method like it is using the middle tier.
            //RunTestsAgainstMiddleTier();
        }
Example #7
0
        private void butRun_Click(object sender, EventArgs e)
        {
            textResults.Text = "";
            Application.DoEvents();
            Cursor = Cursors.WaitCursor;
            if (!DatabaseTools.SetDbConnection("unittest", false))            //if database doesn't exist
            {
                DatabaseTools.SetDbConnection("", false);
                textResults.Text += DatabaseTools.FreshFromDump(false);              //this also sets database to be unittest.
            }
            else
            {
                textResults.Text += DatabaseTools.ClearDb();
            }
            try{
                textResults.Text += BenefitT.BenefitComputeRenewDate();
            }
            catch (Exception ex) {
                textResults.Text += ex.Message;              //failed
            }
            try {
                textResults.Text += ToothT.FormatRanges();
            }
            catch (Exception ex) {
                textResults.Text += ex.Message;              //failed
            }
            int specificTest = 0;

            try {
                Application.DoEvents();
                specificTest      = PIn.Int(textSpecificTest.Text);         //typically zero
                textResults.Text += AllTests.TestOneTwo(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "1&2: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThree(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "3: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestFour(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "4: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestFive(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "5: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestSix(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "6: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestSeven(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "7: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestEight(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "8: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestNine(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "9: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "10: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestEleven(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "11: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwelve(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "12: Failed. " + ex.Message + "\r\n";
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "13: Failed. " + ex.Message + "\r\n";
            }
            //try {//There is a phantom TestFourteen that has been commented out. It is similary to TestOne.
            //  Application.DoEvents();
            //  textResults.Text+=AllTests.TestFourteen(specificTest);
            //}
            //catch(Exception ex) {
            //  textResults.Text+="14: Failed. "+ex.Message+"\r\n";
            //}
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestFourteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "14: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestFifteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "15: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestSixteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "16: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestSeventeen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "17: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestEighteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "18: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestNineteen(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "19: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwenty(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "20: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyOne(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "21: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyTwo(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "22: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyThree(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "23: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyFour(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "24: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyFive(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "25: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentySix(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "26: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentySeven(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "27: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyEight(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "28: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestTwentyNine(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "29: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirty(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "30: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirtyOne(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "31: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirtyTwo(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "32: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirtyThree(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "33: Failed. " + ex.Message;
            }
            try {
                Application.DoEvents();
                textResults.Text += AllTests.TestThirtyFour(specificTest);
            }
            catch (Exception ex) {
                textResults.Text += "34: Failed. " + ex.Message;
            }
            textResults.Text += "Done";
            Cursor            = Cursors.Default;
        }