public void btnOK_Click(object sender, EventArgs e) { int total; int clrIndex; int failed = 0; int fndExcep; object[] tmpArray; string[,] currList; string endTime; string hrs; string mins; string secs; string timeString; string dirPth; string suffFile; string slctString; string suiteName; string tmpID; string caseName; string fileName = ""; string fldrString = ""; string pth = ""; Control.ControlCollection btnRadio; DateTime tmp; TimeSpan fnlTime; DateTime startTime; clrIndex = 0; suffFile = ""; btnRadio = slctBrowser.Controls; //disable all the controls on the form lstTestSuite.Enabled = false; btnOK.Enabled = false; btnCancel.Enabled = false; btnDeslctAllAvailable.Enabled = false; btnSelect.Enabled = false; btnSlctAllAvailable.Enabled = false; lstAvailableTest.Enabled = false; lstSelectedTest.Enabled = false; lstCaseSelect.Enabled = false; lstTestSuite.Enabled = false; label11.Text = "Total Tests: "; label12.Text = "Passed Tests: "; label13.Text = "Failed Tests: "; //populate an array with the list of items currently in the Selected Items box currList = new string[lstCaseSelect.Items.Count, 2]; total = lstCaseSelect.Items.Count; if (datSource != "DB") { for (int i = 0; i < lstCaseSelect.Items.Count; i++) { slctString = lstCaseSelect.Items[i].ToString(); getVal(slctString, out suiteName, out caseName); currList[i, 0] = suiteName; currList[i, 1] = caseName; } } else { for (int i = 0; i < lstCaseSelect.Items.Count; i++) { //set the test case variable currList[i, 1] = lstCaseSelect.Items[i].ToString(); //get a one item array with the regression suite id from the test table tmpArray = db_access("SELECT regression_suite_id FROM test WHERE name = '" + currList[i, 1] + "'"); tmpID = Convert.ToString(tmpArray[0]); tmpArray = db_access("SELECT name FROM regression_suite WHERE id = '" + tmpID + "'"); currList[i, 0] = Convert.ToString(tmpArray[0]); } //there's no way to } //Setup the directory where the results file will be stored dirPth = Application.StartupPath + "\\Results"; tmp = DateTime.Now; //date-time at the time of test running suffFile = tmp.Month.ToString() + tmp.Day.ToString() + tmp.Year.ToString().Substring(2, 2) + tmp.Hour.ToString() + tmp.Minute.ToString() + tmp.Second.ToString(); //set the date-time value to a string fileName = "Result_" + suffFile + ".html"; fldrString = "Result_" + suffFile; pth = dirPth + "\\" + fileName; //create a result text file and write a beginning message TextFileOps.Open(pth); //start timer1 to calculate the complete test run timer1.Start(); startTime = DateTime.Now; tstObject_FF.faillst = ""; for (int tst = 0; tst < currList.GetLength(0); tst++) { //get the current date/time value and set to a string currTime = DateTime.Now; suffFile = currTime.ToString("MMddhhmmss"); lstCaseSelect.SetSelected(tst, true); txtSuiteRunning.Text = currList[tst, 0]; txtTestRunning.Text = currList[tst, 1]; timer2.Start(); //run this test runFunction(currList[tst, 0], currList[tst, 1], btnRadio, pth, out fndExcep); //stop test timer timer2.Stop(); //set the final time and format each element fnlTime = DateTime.Now - currTime; timeString = fnlTime.ToString(); hrs = fnlTime.Hours.ToString(); hrs = fmtTime(hrs); mins = fnlTime.Minutes.ToString(); mins = fmtTime(mins); secs = fnlTime.Seconds.ToString(); secs = fmtTime(secs); endTime = hrs + ":" + mins + ":" + secs; //Write the endTime to the test results TextFileOps.Write(pth, "This test run completed in: " + endTime + "\r\n", clrIndex = 0); TextFileOps.Write(pth, "", clrIndex); lstCaseSelect.SetSelected(tst, false); } //Send message to result file noting the end of the suite for (int a = 0; a < 1; a++) { TextFileOps.Write(pth, "End Test Run.........." + "\r\n", clrIndex); } TextFileOps.Write(pth, "Failed Tests: ", clrIndex); switch (radnum) { case 0: TextFileOps.Write(pth, tstObject_FF.faillst + "\r\n", clrIndex); foreach (char c in tstObject_FF.faillst) { if (c == ',') { failed++; } } break; case 1: TextFileOps.Write(pth, tstObject_Chrome.faillst + "\r\n", clrIndex); foreach (char c in tstObject_Chrome.faillst) { if (c == ',') { failed++; } } break; case 2: TextFileOps.Write(pth, tstObject_IE.faillst + "\r\n", clrIndex); foreach (char c in tstObject_IE.faillst) { if (c == ',') { failed++; } } break; default: TextFileOps.Write(pth, tstObject_FF.faillst + "\r\n", clrIndex); break; } label11.Text += total; label12.Text += (total - failed); label13.Text += failed; //write closing tags to result file TextFileOps.Write(pth, "</html>", clrIndex = 100); TextFileOps.Write(pth, "</body>", clrIndex = 100); //show the result file Process.Start(pth); //re-enable all the controls on the form lstTestSuite.Enabled = true; btnOK.Enabled = true; btnCancel.Enabled = true; btnDeslctAllAvailable.Enabled = true; btnSelect.Enabled = true; btnSlctAllAvailable.Enabled = true; lstAvailableTest.Enabled = true; lstSelectedTest.Enabled = true; lstCaseSelect.Enabled = true; lstTestSuite.Enabled = true; //enable the test suite selector field at the conclusion of the test lstTestSuite.Enabled = true; //stop timer1 and post results to the GUI timer1.Stop(); currTime = DateTime.Now; fnlTime = (currTime - startTime); hrs = fnlTime.Hours.ToString(); hrs = fmtTime(hrs); mins = fnlTime.Minutes.ToString(); mins = fmtTime(mins); secs = fnlTime.Seconds.ToString(); secs = fmtTime(secs); endTime = hrs + ":" + mins + ":" + secs; lblTimer.Text = endTime; boxPerms(); }