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}"); }
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); }
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); }