public void Get_Handlers_For_Event_Should_Return_All_Handlers() { var subscriptionManager = new EventBusSubscriptionManager(); subscriptionManager.AddSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); subscriptionManager.AddSubscription <TestIntegrationEvent, TestOtherIntegrationEventHandler>(); var handlers = subscriptionManager.GetHandlersForEvent <TestIntegrationEvent>(); Assert.Equal(2, handlers.Count()); }
public void After_One_Event_Subscription_Should_Contain_The_Event() { var subscriptionManager = new EventBusSubscriptionManager(); subscriptionManager.AddSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); Assert.True(subscriptionManager.HasSubscriptionsForEvent <TestIntegrationEvent>()); }
public void After_All_Subscriptions_Are_Deleted_Events_Should_No_Longer_Exists() { var subscriptionManager = new EventBusSubscriptionManager(); subscriptionManager.AddSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); subscriptionManager.RemoveSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); Assert.False(subscriptionManager.HasSubscriptionsForEvent <TestIntegrationEvent>()); }
public void Deleting_Last_Subscription_Should_Raise_On_Deleted_Event() { bool raised = false; var subscriptionManager = new EventBusSubscriptionManager(); subscriptionManager.OnEventRemoved += (o, e) => raised = true; subscriptionManager.AddSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); subscriptionManager.RemoveSubscription <TestIntegrationEvent, TestIntegrationEventHandler>(); Assert.True(raised); }
public void Subscribe <TEvent, THandler>() where TEvent : Event where THandler : IEventHandler <TEvent> { _subscriptionManager.AddSubscription <TEvent, THandler>(); }