예제 #1
0
        /// <summary>
        /// Gets called after the run button was clicked.
        /// </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();
            }
            CompileWorkerArgs args = new CompileWorkerArgs
            {
                CompileToSingleDll = radioSingleDll.Checked,
                DestinationPath    = radioSingleDll.Checked ? txtDllName.Text : txtSaveDir.Text
            };

            args.TestCases.AddRange(radioAll.Checked ? CoreData.Instance.TestCaseModel.TestCases.OfType <TestCaseCSharp>() : selectedTestCases.OfType <TestCaseCSharp>());
            CoreData.Instance.Messages.Add(new Message(MessageSeverity.Info, "Start to compile " + args.TestCases.Count + " test cases..."));
            backgroundWorker.RunWorkerAsync(args);
        }
예제 #2
0
        /// <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)
        {
            CompileWorkerArgs args = e.Argument as CompileWorkerArgs;

            if (args != null)
            {
                if (args.CompileToSingleDll)
                {
                    backgroundWorker.ReportProgress(0);
                    TestCaseRunner.Instance.Compile(args.TestCases, args.DestinationPath);
                    backgroundWorker.ReportProgress(100);
                }
                else
                {
                    string testCaseDirectory = CoreData.Instance.TestCaseModel.TestCaseDirectory;
                    int    step = 0;
                    foreach (TestCaseCSharp testCase in args.TestCases)
                    {
                        string path = "";
                        if (testCase.Path.StartsWith(testCaseDirectory))
                        {
                            path = testCase.Path.Substring(testCaseDirectory.Length);
                            // Remove a leading '\' otherwise Path.Combine doesn't work.
                            if (path.StartsWith("\\"))
                            {
                                path = path.Substring(1);
                            }
                        }
                        path = Path.Combine(args.DestinationPath, path);
                        Directory.CreateDirectory(path);
                        TestCaseRunner.Instance.Compile(new[] { testCase }, Path.Combine(path, testCase.Name + ".dll"));
                        step++;
                        backgroundWorker.ReportProgress((int)(((double)step / args.TestCases.Count) * 100));
                    }
                }
            }
        }