示例#1
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);
        }
示例#2
0
        //Step 1: Start in SchemaCrudProposedTest.  It is a series of proposed test methods (although not true crud).
        //   Manually build some functional C# code that will make changes to the db when called.
        //Step 2: In FormUnitTests, check the radiobutton for "Test proposed crud".  Click the Schema button.
        //   It then calls each of the methods in the proposed crud, making sure that they don't crash and that each method makes valid calls to db.
        //   There can still be errors if the crud queries don't crash, but still fail to perform the expected action.
        //   So the ending schema should be checked for expected indexes, triggers, etc.
        //   When the unit test Core Types button is clicked, some schema problems can be caught by failures at that point.
        //Step 3: In the CrudGenerator project, run with the Schema box checked in order to generate SchemaCrudTest.
        //   SchemaCrudTest will not actually be used.  It is simply to test the code generation ability.
        //Step 4: In FormUnitTests, check the radiobutton for "Compare proposed to generated".  Click the Schema button.
        //   It will compare SchemaCrudProposedTest to the generated SchemaCrudTest, and then notify the user whether they match or not.
        //   If they don't match, alter CrudGenerator in order to produce the exact code needed.
        //Step 5: (Jordan only) Improve CrudGenerator to generate similar code on demand.  This happens in three different situations:
        //   a. Code is generated for the unit testing above.
        //   b. Code is generated when a missing table or column is detected.
        //   c. Code is also generated from the CrudGenerator interface to be copied and pasted into the ConvertDatabases class.
        //      This can be done through the UI, or for more complex situations, by setting up some C# in CrudGenerator.

        public static string TestProposedCrud(bool isOracle)
        {
            string retVal = "";

            DatabaseTools.SetDbConnection("unittest", isOracle);
            SchemaCrudProposedTest.AddTableTempcore();
            SchemaCrudProposedTest.AddColumnEndClob();
            SchemaCrudProposedTest.AddColumnEndInt();
            SchemaCrudProposedTest.AddColumnEndTimeStamp();
            SchemaCrudProposedTest.AddIndex();
            SchemaCrudProposedTest.DropColumn();
            retVal += "Proposed Crud passed test.\r\n";
            return(retVal);
        }
示例#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;
 }
示例#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;
 }
示例#5
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;
        }
示例#6
0
        /// <summary></summary>
        public static string CreateTempTable(bool isOracle)
        {
            string retVal = "";

            DatabaseTools.SetDbConnection("unittest", isOracle);
            string command;

            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                command = "DROP TABLE IF EXISTS tempcore";
                DataCore.NonQ(command);
                command = @"CREATE TABLE tempcore (
					TempCoreNum bigint NOT NULL,
					TimeOfDayTest time NOT NULL DEFAULT '00:00:00',
					TimeStampTest timestamp,
					DateTest date NOT NULL DEFAULT '0001-01-01',
					DateTimeTest datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
					TimeSpanTest time NOT NULL DEFAULT '00:00:00',
					CurrencyTest double NOT NULL,
					BoolTest tinyint NOT NULL,
					TextTinyTest varchar(255) NOT NULL, 
					TextSmallTest text NOT NULL,
					TextMediumTest text NOT NULL,
					TextLargeTest mediumtext NOT NULL,
					VarCharTest varchar(255) NOT NULL
					) DEFAULT CHARSET=utf8"                    ;
                DataCore.NonQ(command);
            }
            else              //oracle
            {
                command = "BEGIN EXECUTE IMMEDIATE 'DROP TABLE tempcore'; EXCEPTION WHEN OTHERS THEN NULL; END;";
                DataCore.NonQ(command);
                command = @"CREATE TABLE tempcore (
					TempCoreNum number(20),
					TimeOfDayTest date DEFAULT TO_DATE('0001-01-01','YYYY-MM-DD'),
					TimeStampTest timestamp DEFAULT TO_DATE('0001-01-01','YYYY-MM-DD'),
					DateTest date DEFAULT TO_DATE('0001-01-01','YYYY-MM-DD'),
					DateTimeTest date DEFAULT TO_DATE('0001-01-01','YYYY-MM-DD'),
					TimeSpanTest varchar2(255),
					CurrencyTest number(38,8),
					BoolTest number(3),
					TextTinyTest varchar2(255),
					TextSmallTest varchar2(4000),
					TextMediumTest clob,
					TextLargeTest clob,
					VarCharTest varchar2(255)
					)"                    ;
                DataCore.NonQ(command);
            }
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                command = "DROP TABLE IF EXISTS tempgroupconcat";
                DataCore.NonQ(command);
                command = @"CREATE TABLE tempgroupconcat (
					Names varchar(255)
					) DEFAULT CHARSET=utf8"                    ;
                DataCore.NonQ(command);
            }
            else              //oracle
            {
                command = "BEGIN EXECUTE IMMEDIATE 'DROP TABLE tempgroupconcat'; EXCEPTION WHEN OTHERS THEN NULL; END;";
                DataCore.NonQ(command);
                command = @"CREATE TABLE tempgroupconcat (
					Names varchar2(255)
					)"                    ;
                DataCore.NonQ(command);
            }
            retVal += "Temp tables created.\r\n";
            //retVal+="Temp tables cannot yet be created.\r\n";
            return(retVal);
        }