public void AddCorrelationAppendsToTheMessage()
        {
            CorrelatedExceptionEventArgs e = new CorrelatedExceptionEventArgs("foo", new Exception(), "reported by", false);

            e.AddCorrelationMessage("bar");

            Assert.AreEqual("foo\nbar", e.Message);
        }
            private static void CorrelateUnhandledException(object sender, CorrelatedExceptionEventArgs e)
            {
                ITestContext context = TestContextTrackerAccessor.Instance.CurrentContext;

                if (context != null)
                {
                    e.AddCorrelationMessage(String.Format("The exception occurred while test step '{0}' was running.", context.TestStep.FullName));
                }
            }
Пример #3
0
        private static void HandleUnhandledExceptionNotification(object sender, CorrelatedExceptionEventArgs e)
        {
            if (e.IsRecursive)
            {
                return;
            }

            RuntimeAccessor.Logger.Log(LogSeverity.Error, "Internal error: " + e.GetDescription());
        }
        private static object PolicyPerformsCorrelationThenReportingCallback(object dummy)
        {
            var ex = new Exception("Some exception");
            CorrelatedExceptionEventArgs finalArgs = null;

            UnhandledExceptionPolicy.CorrelateUnhandledException += (sender, e) => e.AddCorrelationMessage("bar");
            UnhandledExceptionPolicy.ReportUnhandledException    += (sender, e) => finalArgs = e;
            UnhandledExceptionPolicy.Report("foo", ex);
            return(finalArgs);
        }
        public void PropertiesContainSameValuesAsWereSetInTheConstructor()
        {
            Exception ex = new Exception();
            CorrelatedExceptionEventArgs e = new CorrelatedExceptionEventArgs("foo", ex, "reported by", true);

            Assert.AreEqual("foo", e.Message);
            Assert.AreEqual("reported by", e.ReporterStackTrace);
            Assert.AreSame(ex, e.Exception);
            Assert.IsTrue(e.IsRecursive);
        }
Пример #6
0
        private static void ReportUnhandledException(object sender, CorrelatedExceptionEventArgs e)
        {
            Form currentOwner;

            lock (syncRoot)
            {
                if (installedOwner == null || installedOwner.IsDisposed)
                {
                    Uninstall();
                    return;
                }

                currentOwner = installedOwner;
            }

            Sync.Invoke(currentOwner, () => ErrorDialog.Show(currentOwner, "Unhandled Exception", e.Message, e.GetDetails()));
        }
Пример #7
0
 private static void LogImpl(CorrelatedExceptionEventArgs e)
 {
     try
     {
         using (var sw = new StreamWriter(Paths.BlackBoxLogFile, true))
         {
             sw.WriteLine(string.Format("Unhandled exception reported at: {0}", DateTime.Now));
             sw.WriteLine(e.Message);
             sw.WriteLine();
             sw.WriteLine(e.GetDescription());
             sw.WriteLine();
         }
     }
     catch
     {
         // eat any exceptions
     }
 }
        public void AddCorrelationThrowsWhenMessageIsNull()
        {
            CorrelatedExceptionEventArgs e = new CorrelatedExceptionEventArgs("foo", new Exception(), "reported by", true);

            e.AddCorrelationMessage(null);
        }
Пример #9
0
 public static void Log(CorrelatedExceptionEventArgs e)
 {
     Logger.Write(bl => LogImpl(e));
 }
Пример #10
0
 private void OnUnhandledException(object sender, CorrelatedExceptionEventArgs e)
 {
     tappedLogger.RecordLogMessage(LogSeverity.Error, e.GetDescription(), null);
 }