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); } }
/// <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); }
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); } }
/// <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);