コード例 #1
0
        public void ConsumerService_Dispose_executesAllDisposeDelegates()
        {
            _consumerService = GetConsumerService();

            _consumerService.StartConsumers("test", null, TotalConsumers);

            _rabbitMqHelper.SendMessage(queueName, "message 1");
            _rabbitMqHelper.SendMessage(queueName, "message 2");

            Thread.Sleep(100);

            _consumerService.Dispose();

            Thread.Sleep(2500);

            Assert.AreEqual(TotalConsumers, _totalStopProcessing, $"_totalStopProcessing: {_totalStopProcessing}");
        }
コード例 #2
0
        public void ConsumerService_ProcessMessage_messageIsReceived(string messageType,
                                                                     int expectedMessageInQueueAfterProcessing)
        {
            _consumerService = GetConsumerService();

            _rabbitMqHelper.SendMessage(queueName, messageType);

            _consumerService.StartConsumers("test", null, TotalConsumers);

            Thread.Sleep(100);

            _consumerService.Dispose();

            var res = _rabbitMqHelper.CreateQueueOrGetInfo(queueName);
            var totalMessagesInQueue = res.MessageCount;

            Assert.AreEqual(expectedMessageInQueueAfterProcessing, totalMessagesInQueue);
        }
コード例 #3
0
        public void ConsumerService_ProcessMessage_WithLimiter_limiterIsCalled()
        {
            const string messageType   = "ok";
            const int    expectedCalls = 1;

            var limiter = new LimiterHelper(Constants.MessageProcessInstruction.OK);

            _consumerService = GetConsumerService();

            _consumerService.Limiter = limiter;

            _rabbitMqHelper.SendMessage(queueName, messageType);

            _consumerService.StartConsumers("test", null, TotalConsumers);

            Thread.Sleep(100);

            _consumerService.Dispose();

            Assert.AreEqual(expectedCalls, limiter.TotalCalls);
        }