コード例 #1
0
        //   ''**************************************
        //   '*  Name:       CalcTest
        //   '*  Purpose:    This application contains code to
        //   '*              test the calculator accessory addition capability.
        //   '*
        //   '*              It is the Template for the Chapter 5-4 Exercise.
        //   '*              THIS APPLICATION WILL NOT RUN UNTIL STEPS OF THE EXERCISE ARE FOLLOWED!!
        //   '*
        //   '*  Author:     M. Sweeney
        //   '*  Date Created: 6/15/2005
        //   '*  Inputs:
        //   '*  Expected Result: That the calculator will add numbers correctly 1 to 100 for a total of 10100
        //   '*  Modification History:
        //   '*  Name:       Date:       Purpose:
        //   '*
        //   '**************************************
        private void cmdTest_Click(object sender, EventArgs e)
        {
            DateTime StartTime;
            TimeSpan Interval;
            String   strTotal = "";
            Int32    CalcProcessID;
            Int16    I;

            TestLib.Logfile = "c:\\Calclog.txt";
            CalcProcessID   = TestLib.StartProgram("Calc.exe");

            //ADD CODE HERE!!!


            if (Convert.ToInt32(strTotal) == 10100)
            {
                TestLib.LogtoFile("Test Passed Expected: 10100 Actual : " + strTotal);
            }
            else
            {
                TestLib.LogtoFile("Test Failed Expected: 10100 Actual : " + strTotal);
            }
            Interval = DateTime.Now - StartTime;

            lblTime.Text = Interval.TotalSeconds.ToString();
            TestLib.LogtoFile("Total Elapsed time: " + lblTime.Text);

            TestLib.CloseProgram("calc");
            cmdLog.Enabled = true;
        }
コード例 #2
0
        //   ''**************************************
        //   '*  Name:       CalcTest
        //   '*  Purpose:    This application contains code to
        //   '*              test the calculator accessory addition capability.
        //   '*
        //   '*              It is the answer for the Chapter 5-4 Exercise.
        //   '*
        //   '*  Author:     M. Sweeney
        //   '*  Date Created: 6/15/2005
        //   '*  Inputs:
        //   '*  Expected Result: That the calculator
        //   '*  Modification History:
        //   '*  Name:       Date:       Purpose:
        //   '*
        //   '**************************************
        private void cmdTest_Click(object sender, EventArgs e)
        {
            DateTime StartTime;
            TimeSpan Interval;
            String   strTotal = "";
            Int32    CalcProcessID;
            Int16    I;

            TestLib.Logfile = "c:\\Calclog.txt";
            CalcProcessID   = TestLib.StartProgram("Calc.exe");
            System.Threading.Thread.Sleep(1000);

            StartTime = DateTime.Now;
            Interaction.AppActivate(CalcProcessID);
            for (I = 1; I <= 100; I++)
            {
                SendKeys.SendWait(I + "{+}");
            }
            SendKeys.SendWait("=");
            SendKeys.SendWait("^c");
            strTotal = Clipboard.GetData(DataFormats.Text).ToString();

            // if statement
            if (Convert.ToInt32(strTotal) == 10100)
            {
                TestLib.LogtoFile("Test Passed Expected: 10100 Actual : " + strTotal);
            }
            else
            {
                TestLib.LogtoFile("Test Failed Expected: 10100 Actual : " + strTotal);
            }
            Interval = DateTime.Now - StartTime;

            lblTime.Text = Interval.TotalSeconds.ToString();
            TestLib.LogtoFile("Total Elapsed time: " + lblTime.Text);

            TestLib.CloseProgram("calc");
            cmdLog.Enabled = true;
        }