public void CallbackIsCalledOnReceivedEvent(string queue, string message)
        {
            // Arrange
            using var context = new RabbitMqContextBuilder()
                                .WithConnectionString("amqp://*****:*****@localhost")
                                .WithExchange("HelloExchange")
                                .CreateContext();

            bool messageReceived = false;

            using var receiver = context.CreateMessageReceiver(queue, new [] { "#" });
            receiver.StartReceivingMessages();
            receiver.StartHandlingMessages(e => messageReceived = true);

            var eventMessage = new EventMessage
            {
                Body          = Encoding.Unicode.GetBytes(message),
                Timestamp     = 10,
                CorrelationId = Guid.NewGuid(),
                Topic         = "irrelevant",
                EventType     = "TestEvent"
            };

            // Act
            var sender = context.CreateMessageSender();

            sender.SendMessage(eventMessage);

            Thread.Sleep(WaitTime);

            // Assert
            Assert.AreEqual(true, messageReceived);
        }
        public void CallbackIsCalledOnReceivedEventWithSpecificTopic(string topicPattern, string topic, bool expected)
        {
            // Arrange
            using IBusContext <IConnection> context = new RabbitMqContextBuilder()
                                                      .WithConnectionString("amqp://*****:*****@localhost")
                                                      .WithExchange("HelloExchange")
                                                      .CreateContext();

            bool messageReceived = false;

            using var receiver = context.CreateMessageReceiver("topic.queue.test", new [] { topicPattern });
            receiver.StartReceivingMessages();
            receiver.StartHandlingMessages(e => messageReceived = true);

            var eventMessage = new EventMessage
            {
                Body          = Encoding.Unicode.GetBytes("TestMessage"),
                Timestamp     = 10,
                CorrelationId = Guid.NewGuid(),
                Topic         = topic,
                EventType     = "TestEvent"
            };

            // Act
            var sender = context.CreateMessageSender();

            sender.SendMessage(eventMessage);

            Thread.Sleep(WaitTime);

            // Assert
            Assert.AreEqual(messageReceived, expected);
        }
        public void PausePausesReceivingMessages(long timestamp)
        {
            // Arrange
            using IBusContext <IConnection> context = new RabbitMqContextBuilder()
                                                      .WithConnectionString("amqp://*****:*****@localhost")
                                                      .WithExchange("HelloExchange")
                                                      .CreateContext();

            bool messageReceived = false;

            using var receiver = context.CreateMessageReceiver("topic.queue.test", new [] { "test" });
            receiver.StartReceivingMessages();
            receiver.StartHandlingMessages(e => messageReceived = true);

            var eventMessage = new EventMessage
            {
                Body          = Encoding.Unicode.GetBytes("TestMessage"),
                Timestamp     = timestamp,
                CorrelationId = Guid.NewGuid(),
                Topic         = "test",
                EventType     = "TestEvent"
            };

            // Act
            receiver.Pause();

            var sender = context.CreateMessageSender();

            sender.SendMessage(eventMessage);

            Thread.Sleep(WaitTime);

            // Assert
            Assert.AreEqual(false, messageReceived);
        }