示例#1
0
        public void After_One_Event_Subscription_Should_Contain_The_Event()
        {
            var subscriptionManager = new EventBusSubscriptionManager();

            subscriptionManager.AddSubscription <TestIntegrationEvent, TestIntegrationEventHandler>();
            Assert.True(subscriptionManager.HasSubscriptionsForEvent <TestIntegrationEvent>());
        }
示例#2
0
        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>());
        }
示例#3
0
        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());
        }
示例#4
0
        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);
        }
示例#5
0
        public RabbitMQEventBus(
            IPersistentConnection <IModel> connection,
            IServiceProvider provider,
            string exchangeName = "R.Boobus",
            string queueName    = "R.Boobus.Queue")
        {
            _connection   = connection;
            _provider     = provider;
            _exchangeName = exchangeName;

            _subscriptionManager = new EventBusSubscriptionManager();
            _subscriptionManager.OnEventRemoved += OnSubscriptionManagerEventRemoved;
            _subscriptionManager.OnEventAdded   += OnSubscriptionManagerEventAdded;
            _queueName = queueName;

            _consumerChannel = RegisterMessageListener();
        }
示例#6
0
        public void After_Creation_Should_Be_Empty()
        {
            var subscriptionManager = new EventBusSubscriptionManager();

            Assert.True(subscriptionManager.IsEmpty);
        }