Esempio n. 1
0
 /// <summary>
 /// Gets called after the run button is pressed and starts the process.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">More information about the event.</param>
 private void cmdRun_Click(object sender, EventArgs e)
 {
   EnableControls(false);
   if(Settings.Default.OptionsClearMessagesOnRun)
   {
     CoreData.Instance.Messages.Clear();
   }
   VisitorWorkerArgs args = new VisitorWorkerArgs
                              {
                                RunTestCases = chkRunTestCases.Checked,
                                DestinationPath = txtSaveLocation.Text
                              };
   foreach(string item in lstVisitors.CheckedItems)
   {
     args.Visitors.Add(item);
   }
   args.TestCases.AddRange(radioAll.Checked ? CoreData.Instance.TestCaseModel.TestCases : selectedTestCases);
   CoreData.Instance.Messages.Add(new Message(MessageSeverity.Info, "Start to execute " + args.Visitors.Count + " visitors on " + args.TestCases.Count + " test cases..."));
   backgroundWorker.RunWorkerAsync(args);
 }
        /// <summary>
        /// Gets called start the background working process.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">More information about the event.</param>
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            VisitorWorkerArgs args = e.Argument as VisitorWorkerArgs;

            if (args != null)
            {
                double steps = args.TestCases.Count * args.Visitors.Count;
                double step  = 0;
                foreach (TestCase testCase in args.TestCases)
                {
                    if (testCase.CurrentResult == null && args.RunTestCases)
                    {
                        // Run the test case.
                        if (testCase is TestCaseCSharp)
                        {
                            TestCaseRunner.Instance.CompileAndReflect(testCase as TestCaseCSharp);
                        }
                        else
                        {
                            TestCaseRunner.Instance.Reflect(testCase as TestCaseAssembly);
                        }
                    }
                    if (testCase.CurrentResult != null)
                    {
                        // Run the visitors and store the result.
                        foreach (string visitor in args.Visitors)
                        {
                            RunAndSaveVisitor(visitor, testCase, args.DestinationPath);
                            step++;
                        }
                    }
                    else
                    {
                        step += args.Visitors.Count;
                    }
                    backgroundWorker.ReportProgress((int)((step / steps) * 100));
                }
            }
        }