Ejemplo n.º 1
0
        public void EnqueueTest()
        {
            var queue = new QueueRabbitMq(
                new ConnectionFactory(),
                new FileConfigurationRabbitMq(),
                new BinarySerializer(),
                new NullLogger());

            queue.Enqueue(new QueueMessage {
                Id = Guid.NewGuid(), Message = "Тестовое сообщение"
            }, "Test");
        }
Ejemplo n.º 2
0
        public void SubscribeTest()
        {
            const int count = 10;

            var queue = new QueueRabbitMq(
                new ConnectionFactory(),
                new FileConfigurationRabbitMq(),
                new BinarySerializer(),
                new NullLogger());

            var index = 0;
            var stop  = false;

            queue.Subscribe(
                "TestSubscribe",
                message =>
            {
                index++;

                if (index == count)
                {
                    stop = true;
                }

                return(true);
            });

            for (var i = 0; i < count; i++)
            {
                queue.Enqueue(
                    new QueueMessage {
                    Id = Guid.NewGuid(), Message = $"Тестовое сообщение №{i}"
                },
                    "TestSubscribe");
            }

            while (!stop)
            {
            }

            Assert.AreEqual(count, index);
        }