Example #1
0
        public virtual void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

            foreach (var action in this.Actions)
            {
                action.Invoke(fakeObjectCall);
            }

            this.applicator.Invoke(fakeObjectCall);
            this.ApplyOutAndRefParametersValueProducer(fakeObjectCall);

            if (this.CallBaseMethod)
            {
                if (EventCall.TryGetEventCall(fakeObjectCall, out var eventCall) && eventCall.IsEventRaiser())
                {
                    throw new InvalidOperationException(ExceptionMessages.CannotRaiseEventWhenCallingBaseMethod);
                }

                fakeObjectCall.CallBaseMethod();
            }
            else if (this.CallWrappedMethodOn is object wrappedObject)
            {
                fakeObjectCall.CallWrappedMethod(wrappedObject);
            }
        }
Example #2
0
        /// <summary>
        /// Applies an action to the call, might set a return value or throw
        /// an exception.
        /// </summary>
        /// <param name="fakeObjectCall">The call to apply the interceptor to.</param>
        public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            if (EventCall.TryGetEventCall(fakeObjectCall, out var eventCall) && eventCall.IsEventRaiser())
            {
                throw new InvalidOperationException(ExceptionMessages.WrappingFakeCannotRaiseEvent);
            }

            fakeObjectCall.CallWrappedMethod(this.WrappedObject);
        }
Example #3
0
        public virtual void Apply(IInterceptedFakeObjectCall fakeObjectCall)
        {
            Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

            foreach (var action in this.Actions)
            {
                action.Invoke(fakeObjectCall);
            }

            this.applicator.Invoke(fakeObjectCall);
            this.ApplyOutAndRefParametersValueProducer(fakeObjectCall);

            if (this.CallBaseMethod)
            {
                fakeObjectCall.CallBaseMethod();
            }
            else if (this.CallWrappedMethodOn is object wrappedObject)
            {
                fakeObjectCall.CallWrappedMethod(wrappedObject);
            }
        }
Example #4
0
 /// <summary>
 /// Applies an action to the call, might set a return value or throw
 /// an exception.
 /// </summary>
 /// <param name="fakeObjectCall">The call to apply the interceptor to.</param>
 public void Apply(IInterceptedFakeObjectCall fakeObjectCall) => fakeObjectCall.CallWrappedMethod(this.WrappedObject);