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 Unsubscribe <TEvent, THandler>() where TEvent : Event where THandler : IEventHandler <TEvent> { _subscriptionManager.RemoveSubscription <TEvent, THandler>(); }