예제 #1
0
 public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
 {
     if (EventCall.TryGetEventCall(fakeObjectCall, out var eventCall))
     {
         this.fakeManager.EventCallHandler.HandleEventCall(eventCall);
     }
 }
예제 #2
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);
            }
        }
예제 #3
0
        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);
                }
            });
        }
예제 #4
0
            public bool IsApplicableTo(IFakeObjectCall fakeObjectCall)
            {
                Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));

                return(EventCall.TryGetEventCall(fakeObjectCall, out _));
            }
예제 #5
0
 internal bool Matches(IFakeObjectCall call) => EventCall.TryGetEventCall(call, out var eventCall) && this.Matches(eventCall);