public void Apply(IInterceptedFakeObjectCall fakeObjectCall) { if (EventCall.TryGetEventCall(fakeObjectCall, out var eventCall)) { this.fakeManager.EventCallHandler.HandleEventCall(eventCall); } }
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); } }
private static void ManageEvents(object fake, Func <EventCall, bool> eventCallPredicate) { Guard.AgainstNull(fake, nameof(fake)); var manager = Fake.GetFakeManager(fake); A.CallTo(fake) .WithVoidReturnType() .Where( call => EventCall.TryGetEventCall(call, out var eventCall) && eventCallPredicate(eventCall), writer => { }) // This call spec will never be asserted, so we don't need to write a description .Invokes(call => { if (EventCall.TryGetEventCall(call, out var eventCall)) { manager.EventCallHandler.HandleEventCall(eventCall); } }); }
public bool IsApplicableTo(IFakeObjectCall fakeObjectCall) { Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall)); return(EventCall.TryGetEventCall(fakeObjectCall, out _)); }
internal bool Matches(IFakeObjectCall call) => EventCall.TryGetEventCall(call, out var eventCall) && this.Matches(eventCall);