public void PublishWithNoSubscribersDoesNotCallHandler( Mock<IEventHandler<TestEvent>> testHandler, TestEvent eventData) { DomainEvents.ClearAllSubscriptions(); DomainEvents.Publish(eventData); testHandler.Verify(a => a.Handle(eventData), Times.Never()); }
public void PublishRaisesEventsToSubscriber( Mock<IEventHandler<TestEvent>> testHandler, TestEvent eventData) { DomainEvents.Subscribe(testHandler.Object); DomainEvents.Publish(eventData); testHandler.Verify(a => a.Handle(eventData), Times.Once()); }
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()); }
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()); }
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()); }