Example #1
0
        public void UIProvider_AutoUIMode_Normal()
        {
            Settings.UIProvider = UIProvider.Auto;
            Settings.UIMode     = UIMode.Normal;

            MessageBox.Show("Now click 'Quit'", "User Input Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            MessageBox.Show("Now click 'Continue'", "User Input Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));

            // By default, Visual Studio loads some WinForms dlls so WinForms dialogs will be displayed via auto selection
            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIProvider: Auto" + Environment.NewLine + "UIMode: Normal" + Environment.NewLine + Environment.NewLine
                    + "Did you see a Normal WinForms error dialog?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #2
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                return(uiDialogResult.Execution);
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return(ExecutionFlow.BreakExecution);                // Since an internal exception occured
            }
        }
Example #3
0
        public void ExceptionThread_Task()
        {
            // By default UI is not shown for task exceptions
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Task, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.No,
                MessageBox.Show(
                    "ExceptionThread: Task" + Environment.NewLine + Environment.NewLine + "Did you see any UI on the screen?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #4
0
        public void UIMode_None()
        {
            Settings.UIMode = UIMode.None;

            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.UI_WinForms, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.No,
                MessageBox.Show(
                    "ExceptionThread: Task" + Environment.NewLine + Environment.NewLine + "Did you see any UI on the screen?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #5
0
        public void UIProvider_WinFormsUIMode_Minimal()
        {
            Settings.UIProvider = UIProvider.WinForms;
            Settings.UIMode     = UIMode.Minimal;

            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.UI_WinForms, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIProvider: WinForms" + Environment.NewLine + "UIMode: Minimal" + Environment.NewLine + Environment.NewLine
                    + "Did you see a Minimal WinForms message box?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #6
0
        public void UIMode_AutoExceptionThread_WPF()
        {
            // Auto mode displays minimal UI by default
            Settings.UIMode = UIMode.Auto;

            // UIMode:Auto and exception on WPF thread
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.UI_WPF, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIMode: Auto" + Environment.NewLine + "ExceptionThread: WPF" + Environment.NewLine + Environment.NewLine
                    + "Did you see a Minimal WPF message box?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #7
0
        public void UIMode_AutoExceptionThread_Main()
        {
            // Auto mode displays minimal UI by default
            Settings.UIMode = UIMode.Auto;

            // By default UIFixture loads System.Windows.Forms so this should not behave as console but WinForms UI
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIMode: Auto" + Environment.NewLine + "ExceptionThread: Main" + Environment.NewLine + "Loaded Assembly: System.Windows.Forms"
                    + Environment.NewLine + Environment.NewLine + "Did you see a Minimal WinForms message box?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #8
0
        public void UIProvider_AutoUIMode_Minimal()
        {
            Settings.UIProvider = UIProvider.Auto;
            Settings.UIMode     = UIMode.Minimal;

            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.UI_WinForms, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            // By default, Visual Studio loads some WinForms dlls so WinForms dialogs will be displayed via auto selection
            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIProvider: Auto" + Environment.NewLine + "UIMode: Minimal" + Environment.NewLine + Environment.NewLine
                    + "Did you see a Minimal WinForms message box?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #9
0
        public void UIProvider_ConsoleUIMode_Normal()
        {
            Settings.UIProvider = UIProvider.Console;
            Settings.UIMode     = UIMode.Normal;

            var consoleOut = new StringWriter();

            Console.SetOut(consoleOut);

            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIProvider: Console" + Environment.NewLine + "UIMode: Normal" + Environment.NewLine + Environment.NewLine + "Console Message: " + consoleOut
                    + Environment.NewLine + "Is the message written to the console right?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }
Example #10
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                // If NBug is configured not to delay error reporting and user did not select to exit the app immediately,
                // start dispatching the bug report right away
                if (!Settings.DeferredReporting)
                {
                    new NBug.Core.Submission.Dispatcher();
                }

                return(uiDialogResult.Execution);
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return(ExecutionFlow.BreakExecution);                // Since an internal exception occured
            }
        }
Example #11
0
        public void UIProvider_WinFormsUIMode_Full()
        {
            Settings.UIProvider = UIProvider.WinForms;
            Settings.UIMode     = UIMode.Full;

            MessageBox.Show("Now click 'Send and Quit'", "User Input Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));

            MessageBox.Show("Now click 'Quit'", "User Input Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Assert.Equal(
                UISelector.DisplayBugReportUI(ExceptionThread.Main, this.serializableException, this.report),
                new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.DoNotSend));

            Assert.Equal(
                DialogResult.Yes,
                MessageBox.Show(
                    "UIProvider: WinForms" + Environment.NewLine + "UIMode: Full" + Environment.NewLine + Environment.NewLine
                    + "Did you see a Full WinForms error dialog?",
                    "Assert Question",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question));
        }