示例#1
0
        protected override void GetActivitySpecificTrace(TraceGroup traceGroup)
        {
            // This lets the old Hint still work
            foreach (TestCatch testCatch in this.Catches)
            {
                if (testCatch.HintHandleException)
                {
                    if (!TracingHelper.CatchAnException(testCatch.ExceptionType, Try))
                    {
                        //Log.TraceInternal("Warning- Catch marked as handle, isnt handling exception.");
                    }
                    break;
                }
            }

            if (this.Try != null)
            {
                Outcome tryOutcome = Try.GetTrace(traceGroup);

                CaughtExceptionOutcome ceo = tryOutcome as CaughtExceptionOutcome;

                // if state is catching exception
                if (ceo != null)
                {
                    // look for a catch to handle this exception
                    TestCatch testcatch = GetCorrectCatchForException(ceo.ExceptionType);

                    if (testcatch == null)
                    {
                        CurrentOutcome = tryOutcome;
                    }
                    else
                    {
                        // wipe out the CaughtExceptionOutcome in case no body is set
                        CurrentOutcome = Outcome.Completed;

                        if (testcatch.Body != null)
                        {
                            // our return state is the catches return state
                            CurrentOutcome = testcatch.Body.GetTrace(traceGroup);
                        }
                    }
                }
                else
                {
                    CurrentOutcome = tryOutcome;
                }
            }

            if (!(CurrentOutcome is UncaughtExceptionOutcome) && Finally != null)
            {
                Outcome finallyOutcome = this.Finally.GetTrace(traceGroup);
                if (finallyOutcome.DefaultPropogationState != OutcomeState.Completed)
                {
                    CurrentOutcome = finallyOutcome;
                }
            }
        }
示例#2
0
        protected override void GetActivitySpecificTrace(TraceGroup traceGroup)
        {
            CaughtExceptionOutcome ceo = ExpectedOutcome as CaughtExceptionOutcome;

            // stuff the exception type in so we dont always have to do that manually
            if (ceo != null)
            {
                if (ceo.ExceptionType == null)
                {
                    ceo.ExceptionType = typeof(TException);
                }
            }
            else
            {
                UncaughtExceptionOutcome ueo = ExpectedOutcome as UncaughtExceptionOutcome;
                if (ueo != null && ueo.ExceptionType == null)
                {
                    ueo.ExceptionType = typeof(TException);
                }
            }

            base.GetActivitySpecificTrace(traceGroup);
        }