예제 #1
0
 public void PublishWithNoSubscribersDoesNotCallHandler(
    Mock<IEventHandler<TestEvent>> testHandler,
    TestEvent eventData)
 {
     DomainEvents.ClearAllSubscriptions();
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Never());
 }
예제 #2
0
 public void PublishRaisesEventsToSubscriber(
     Mock<IEventHandler<TestEvent>> testHandler,
     TestEvent eventData)
 {
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Once());
 }
예제 #3
0
 public void SubscribersRegisteredAfterClearingAllSubscriptionsGetsNotifiedOfEvents(
     Mock<IEventHandler<TestEvent>> testHandler,
     TestEvent eventData)
 {
     DomainEvents.ClearAllSubscriptions();
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Once());
 }
예제 #4
0
 public void ClearAllSubscriptionsDoesNotRaiseEventsToPreviouslySubscribedClients(
     Mock<IEventHandler<TestEvent>> testHandler,
     TestEvent eventData)
 {
     DomainEvents.Subscribe(testHandler.Object);
     DomainEvents.ClearAllSubscriptions();
     DomainEvents.Publish(eventData);
     testHandler.Verify(a => a.Handle(eventData), Times.Never());
 }
예제 #5
0
        public void PublishRaisesEventsToAllSubscribers(
            IEnumerable<Mock<IEventHandler<TestEvent>>> testHandlers,
            TestEvent eventData)
        {
            foreach (var testHandler in testHandlers)
                DomainEvents.Subscribe(testHandler.Object);

            DomainEvents.Publish(eventData);

            foreach (var testHandler in testHandlers)
                testHandler.Verify(a => a.Handle(eventData), Times.Once());
        }