예제 #1
0
        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);
        }
예제 #2
0
        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 <RC.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)));
        }