Beispiel #1
0
        /// <summary>
        /// Displays the progress dialog and handle exceptions, if any
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="handler"></param>
        public static void CreateReport(Form owner, ReportHandler handler)
        {
            Exception exception = null;

            try
            {
                SynchronizerList.SuspendSynchronization();

                ProgressDialog dialog = new ProgressDialog("Generating report", handler);
                dialog.ShowDialog(owner);
            }
            catch (Exception e)
            {
                exception = e;
            }
            finally
            {
                SynchronizerList.ResumeSynchronization();
            }

            if (handler.Error != null)
            {
                exception = handler.Error;
            }

            if (exception != null)
            {
                MessageBox.Show(owner, exception.Message, "An error has occured", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
            /// <summary>
            ///     Executes the tests in the background thread
            /// </summary>
            public override void ExecuteWork()
            {
                if (Window != null)
                {
                    SynchronizerList.SuspendSynchronization();
                    MarkingHistory.PerformMark(() =>
                    {
                        SubSequence subSequence = TestCase.Enclosing as SubSequence;
                        if (subSequence != null && TestCase.Steps.Count > 0)
                        {
                            Step step  = null;
                            bool found = false;
                            foreach (TestCase current in subSequence.TestCases)
                            {
                                if (found && current.Steps.Count > 0)
                                {
                                    step = (Step)current.Steps[0];
                                    break;
                                }

                                found = (current == TestCase);
                            }

                            Runner runner = Window.GetRunner(subSequence);
                            runner.RunUntilStep(step);
                        }
                    });
                    SynchronizerList.ResumeSynchronization();
                }
            }
            /// <summary>
            ///     Executes the tests in the background thread
            /// </summary>
            public override void ExecuteWork()
            {
                DateTime start = DateTime.Now;

                SynchronizerList.SuspendSynchronization();

                // Compile everything
                EfsSystem.Instance.Compiler.Compile_Synchronous(EfsSystem.Instance.ShouldRebuild);
                EfsSystem.Instance.ShouldRebuild = false;

                Failed = 0;
                ArrayList tests = Dictionary.Tests;

                tests.Sort();
                foreach (Frame frame in tests)
                {
                    Dialog.UpdateMessage("Executing " + frame.Name);

                    const bool ensureCompilationDone = false;
                    int        failedFrames          = frame.ExecuteAllTests(ensureCompilationDone, Settings.Default.CheckForCompatibleChanges);
                    if (failedFrames > 0)
                    {
                        Failed += 1;
                    }
                }
                EfsSystem.Instance.Runner = null;
                SynchronizerList.ResumeSynchronization();

                Span = DateTime.Now.Subtract(start);
            }
Beispiel #4
0
            /// <summary>
            ///     Executes the work in the background task
            /// </summary>
            public override void ExecuteWork()
            {
                SynchronizerList.SuspendSynchronization();

                if (Window != null)
                {
                    Window.SetFrame(Frame);
                    MarkingHistory.PerformMark(() =>
                    {
                        try
                        {
                            // Compile everything
                            Frame.EFSSystem.Compiler.Compile_Synchronous(Frame.EFSSystem.ShouldRebuild);
                            Frame.EFSSystem.ShouldRebuild = false;

                            Failed = 0;
                            ArrayList subSequences = Frame.SubSequences;
                            subSequences.Sort();
                            foreach (SubSequence subSequence in subSequences)
                            {
                                if (subSequence.getCompleted())
                                {
                                    Dialog.UpdateMessage("Executing " + subSequence.Name);

                                    const bool explain        = false;
                                    const bool ensureCompiled = false;
                                    Frame.EFSSystem.Runner    = new Runner(subSequence, explain, ensureCompiled,
                                                                           Settings.Default.CheckForCompatibleChanges);

                                    int testCasesFailed = subSequence.ExecuteAllTestCases(Frame.EFSSystem.Runner);
                                    if (testCasesFailed > 0)
                                    {
                                        subSequence.AddError("Execution failed");
                                        Failed += 1;
                                    }
                                }
                                else
                                {
                                    subSequence.AddWarning(
                                        "Sub sequence not executed because it is not marked as completed");
                                }
                            }
                        }
                        finally
                        {
                            Frame.EFSSystem.Runner = null;
                        }
                    });
                }

                SynchronizerList.ResumeSynchronization();
            }
Beispiel #5
0
        /// <summary>
        ///     Executes the operation in background using a progress handler
        /// </summary>
        /// <param name="mainForm">The enclosing form</param>
        /// <param name="message">The message to display on the dialog window</param>
        /// <param name="allowCancel">Indicates that the opeation can be canceled</param>
        public virtual void ExecuteUsingProgressDialog(Form mainForm, string message, bool allowCancel = true)
        {
            DateTime start = DateTime.Now;

            Util.DontNotify(() =>
            {
                try
                {
                    SynchronizerList.SuspendSynchronization();

                    if (ShowDialog)
                    {
                        Dialog = new ProgressDialog(message, this, allowCancel);
                        mainForm.Invoke((MethodInvoker)(() => Dialog.ShowDialog(mainForm)));
                    }
                    else
                    {
                        ExecuteWork();
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + @"\n" + e.StackTrace, @"Exception raised");
                    // DefaultDesktopOnly option is added in order to avoid exceptions during nightbuild execution
                    MessageBox.Show(e.Message + @"\n" + e.StackTrace, @"Exception raised", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.DefaultDesktopOnly);
                }
                finally
                {
                    Span = DateTime.Now.Subtract(start);
                    SynchronizerList.ResumeSynchronization();
                }
            });
        }