Example #1
0
        /// <summary>
        /// Implements the tracking of invocations for the excuted invocations.
        /// </summary>
        public IMethodReturn Execute(IMethodInvocation invocation, GetNextBehavior next)
        {
            // Allows subsequent extension methods on the fluent API to retrieve the
            // current invocation being performed via the MockContext.
            MockContext.CurrentInvocation = invocation;

            // Determines the current setup according to contextual
            // matchers that may have been pushed to the MockSetup context.
            // Allows subsequent extension methods on the fluent API to retrieve the
            // current setup being performed via the MockContext.
            MockContext.CurrentSetup = MockSetup.Freeze(invocation);

            // While debugging, capture invocation stack traces for easier
            // troubleshooting
            if (Debugger.IsAttached)
            {
                invocation.Context[nameof(Environment.StackTrace)] = invocation.GetStackTrace();
            }

            return(next().Invoke(invocation, next));
        }