public void EnqueueTest() { var queue = new QueueRabbitMq( new ConnectionFactory(), new FileConfigurationRabbitMq(), new BinarySerializer(), new NullLogger()); queue.Enqueue(new QueueMessage { Id = Guid.NewGuid(), Message = "Тестовое сообщение" }, "Test"); }
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); }