public MessageListenerAdapterTest()
        {
            var headers = new Dictionary <string, object>()
            {
                { MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN_VALUE }
            };

            messageProperties = new MessageHeaders(headers);
            adapter           = new MessageListenerAdapter(null);
        }
        public void TestAlternateConstructor()
        {
            var called = new AtomicBoolean(false);
            var dele   = new TestDelegate2(called);

            adapter = new MessageListenerAdapter(null, dele, "MyPojoMessageMethod");
            var bytes = EncodingUtils.GetDefaultEncoding().GetBytes("foo");

            adapter.OnMessage(Message.Create(bytes, messageProperties), null);
            Assert.True(called.Value);
        }
        public void TestTaskReturn()
        {
            var called = new CountdownEvent(1);
            var dele   = new TestAsyncDelegate();

            adapter = new MessageListenerAdapter(null, dele, "MyPojoMessageMethod")
            {
                ContainerAckMode = AcknowledgeMode.MANUAL,
                ResponseExchange = "default"
            };
            var mockChannel = new Mock <IModel>();

            mockChannel.Setup(c => c.CreateBasicProperties()).Returns(new MockRabbitBasicProperties());
            mockChannel.Setup(c => c.BasicAck(It.IsAny <ulong>(), false))
            .Callback(() => called.Signal());
            var bytes   = EncodingUtils.GetDefaultEncoding().GetBytes("foo");
            var message = Message.Create(bytes, messageProperties);

            adapter.OnMessage(message, mockChannel.Object);
            Assert.True(called.Wait(TimeSpan.FromSeconds(10)));
        }