Beispiel #1
0
        public void StartConsumerAlreadyStartedTest()
        {
            var consumer = new AmqpConsumer(channelMock.Object, publisherMock.Object,
                                            builderMock.Object, managerMock.Object);

            consumer.Start(processorMock.Object, queueName);
            Assert.Throws <InvalidOperationException>(() => consumer.Start(processorMock.Object, queueName));
        }
Beispiel #2
0
        public void StartConsumerWithoutQueueTest()
        {
            var consumer = new AmqpConsumer(channelMock.Object, publisherMock.Object,
                                            builderMock.Object, managerMock.Object);

            Assert.Throws <ArgumentNullException>(() => consumer.Start(processorMock.Object, string.Empty));
        }
Beispiel #3
0
        public void StartConsumerTest()
        {
            var consumer = new AmqpConsumer(channelMock.Object, publisherMock.Object,
                                            builderMock.Object, managerMock.Object);

            Assert.True(String.IsNullOrEmpty(consumer.ConsumerTag));
            consumer.Start(processorMock.Object, queueName);
            Assert.False(String.IsNullOrEmpty(consumer.ConsumerTag));
            consumer.Stop();
            Assert.True(String.IsNullOrEmpty(consumer.ConsumerTag));

            channelMock.Verify(c => c.BasicConsume(queueName, false, It.IsAny <string>(),
                                                   It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <IDictionary <string, object> >(),
                                                   It.IsAny <IBasicConsumer>()));
            managerMock.Verify(m => m.EnsureQueue(queueName));
        }