コード例 #1
0
        private void HandleResult(TestResultException e)
        {
            if (e is TestPassedException)
            {
                SetVariationPassed(e.Message);

                /*
                 * Allow all remaining context tasks to be processed before logging PASSED.  This will
                 * hopefully catch exceptions that might be thrown asynchronously.
                 */
                CurrentSuite.BeginInvoke(new DispatcherOperationCallback(LogAndShutdownVariation), null, DispatcherPriority.SystemIdle);
            }
            else if (e is TestFailedException)
            {
                SetVariationFailed(e);
                // Shutdown immediately (do not process further context tasks).
                LogAndShutdownVariation(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handle any kind of exception and convert it into a pass or fail state for the
        /// test.
        ///
        /// If FAIL: fail and shutdown test immediately.
        /// If PASS: process remaining context tasks and then pass and shutdown.
        /// </summary>
        /// <param name="e"></param>
        private void HandleException(Exception e)
        {
            // Ignore future exceptions if the test has already been logged as a failure
            // because this is probably a side-effect of the original failure.
            if (CurrentVariation.Result == VariationResult.Failed)
            {
                return;
            }

            if (e is TestPassedException)
            {
                SetVariationPassed(e.Message);

                /*
                 * Allow all remaining context tasks to be processed before logging PASSED.  This will
                 * hopefully catch exceptions that might be thrown asynchronously.
                 */
                CurrentSuite.BeginInvoke(new DispatcherOperationCallback(LogAndShutdownVariation), null, DispatcherPriority.SystemIdle);
            }
            else
            {
                if (e is TestFailedException)
                {
                    SetVariationFailed(e);
                }
                else
                {
                    string message = e.ToString();

                    // If this exception was thrown from Proxy framework then append the proxy stack trace
                    // for debugging.
                    if (e.Data.Contains("ProxyStackTrace"))
                    {
                        message = e.Message + ":\n" + e.Data["ProxyStackTrace"] + "\n" + e.StackTrace;
                    }
                    SetVariationFailed("Unexpected exception was thrown:\n" + e.GetType().FullName + " - " + message);
                }

                // Shutdown immediately (do not process further context tasks).
                LogAndShutdownVariation(null);
            }
        }