Esempio n. 1
0
        public void QueuePurge_RemovesAllMessagesFromQueue()
        {
            // Arrange
            var node = new RabbitServer();

            using (var model = new FakeModel(node))
            {
                model.QueueDeclarePassive("my_other_queue");
                node.Queues["my_other_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_other_queue"].Messages.Enqueue(new RabbitMessage());

                model.QueueDeclarePassive("my_queue");
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());

                // Act
                model.QueuePurge("my_queue");

                // Assert
                Assert.True(node.Queues["my_queue"].Messages.IsEmpty);
                Assert.False(node.Queues["my_other_queue"].Messages.IsEmpty);
            }
        }
Esempio n. 2
0
        public void QueuePurge_returns_0_if_queue_does_not_exist()
        {
            var node = new RabbitServer();

            using (var model = new FakeModel(node))
            {
                model.QueueDeclare("my_queue");
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());

                var count = model.QueuePurge("my_other_queue");
                Assert.Equal(0u, count);

                Assert.False(node.Queues["my_queue"].Messages.IsEmpty);
            }
        }
Esempio n. 3
0
        public void QueuePurge_removes_all_messages_from_specified_queue()
        {
            var node = new RabbitServer();

            using (var model = new FakeModel(node))
            {
                model.QueueDeclare("my_other_queue");
                node.Queues["my_other_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_other_queue"].Messages.Enqueue(new RabbitMessage());

                model.QueueDeclare("my_queue");
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());
                node.Queues["my_queue"].Messages.Enqueue(new RabbitMessage());

                var count = model.QueuePurge("my_queue");
                Assert.Equal(4u, count);

                Assert.True(node.Queues["my_queue"].Messages.IsEmpty);
                Assert.False(node.Queues["my_other_queue"].Messages.IsEmpty);
            }
        }