void gbw_DoWork(object sender, DoWorkEventArgs e) { object[] param = e.Argument as object[]; string serverName = param[0] as string; string appName = param[1] as string; string dealerName = param[2] as string; MCCTestCase[] tcs = param[3] as MCCTestCase[]; int total = 0, pass = 0, fail = 0; string token = null; MCCTestClient mtc = new MCCTestClient(new MCCTestUrlBuilder(serverName, appName, dealerName)); mtc.OnOutput += mtc_OnOutput; total = tcs.Length; foreach (MCCTestCase tc in tcs) { if (mtc.RunTestCase(tc, ref token)) { pass++; } else { fail++; } (sender as BackgroundWorker).ReportProgress((int)(100.0 * ((float)(pass + fail) / (float)total))); Thread.Sleep(200); } mtc_OnOutput(string.Format("Total cases: {0}, Passed: {1}, Fail: {2}.", total, pass, fail), Color.Yellow); }
void gbw_DoWork(object sender, DoWorkEventArgs e) { object[] param = e.Argument as object[]; string serverName = param[0] as string; string appName = param[1] as string; string dealerName = param[2] as string; MCCTestCase[] tcs = param[3] as MCCTestCase[]; if (tcs.Length < 1) { return; } int total = 0, pass = 0, fail = 0; string token = null; MCCTestClient mtc = new MCCTestClient(new MCCTestUrlBuilder(serverName, appName, dealerName)); mtc.OnOutput += mtc_OnOutput; total = tcs.Length; foreach (MCCTestCase tc in tcs) { this.MarkTestCaseResult(tc.Method, Color.Yellow, "Pending"); } SetStatusLabel(string.Format("In testing ... ({0}/{1})", pass + fail, total)); foreach (MCCTestCase tc in tcs) { this.MarkTestCaseResult(tc.Method, Color.Yellow, "In Progress"); if (mtc.RunTestCase(tc, ref token)) { this.MarkTestCaseResult(tc.Method, Color.LightGreen, "Pass"); pass++; } else { this.MarkTestCaseResult(tc.Method, Color.Red, "Fail"); fail++; } SetStatusLabel(string.Format("In testing ... ({0}/{1})", pass + fail, total)); (sender as BackgroundWorker).ReportProgress((int)(100.0 * ((float)(pass + fail) / (float)total))); Thread.Sleep(200); } string summary = string.Format("Total cases: {0}, Passed: {1}, Fail: {2}.", total, pass, fail); mtc_OnOutput(summary, Color.Yellow); SetStatusLabel(summary); }