public void When_sending_a_message_with_mulitple_inheritance_should_receive_one_copy_at_base_level()
        {
            subject.BuildRoutes(typeof(IFile));

            router.AddDestination("dst");
            router.Link("Example.Types.IMsg", "dst");

            router.Send("Example.Types.IFile", null, null, null, "Hello");

            Assert.That(router.GetAndFinish("dst", out _), Is.EqualTo("Hello"));
            Assert.That(router.GetAndFinish("dst", out _), Is.Null);
        }
        public void When_there_is_no_message_should_return_null()
        {
            messageRouter.GetAndFinish("MyServiceDestination", out _).Returns((string)null);
            var result = messaging.GetMessage <IMetadataFile>("MyServiceDestination");

            Assert.That(result, Is.Null);
        }
Пример #3
0
        /// <summary>
        /// Poll for a waiting message. Returns default(T) if no message.
        /// <para></para>
        /// IMPORTANT: this will immediately remove the message from the broker queue.
        /// Use this only for non-critical transient messages.
        /// <para></para>
        /// For important messages, use `TryStartMessage`
        /// </summary>
        public T GetMessage <T>(string destinationName)
        {
            var messageString = messageRouter.GetAndFinish(destinationName, out var properties);

            if (messageString == null)
            {
                return(default(T));
            }

            try
            {
                return((T)serialiser.DeserialiseByStack(messageString, properties.OriginalType));
            }
            catch
            {
                return(serialiser.Deserialise <T>(messageString));
            }
        }
Пример #4
0
        public void If_I_make_a_link_twice_I_only_get_one_copy_of_each_message()
        {
            router.AddSource("src", null);
            router.AddDestination("dst");

            router.Link("src", "dst");
            router.Link("src", "dst");

            router.Send("src", null, null, null, "Hello");

            Assert.That(router.GetAndFinish("dst", out _), Is.EqualTo("Hello"));
            Assert.That(router.GetAndFinish("dst", out _), Is.Null);
        }
        public void Can_create_a_single_exchange_and_queue_and_send_a_simple_message()
        {
            router.AddSource("exchange_A", null);
            router.AddDestination("queue_A");
            router.Link("exchange_A", "queue_A");

            router.Send("exchange_A", null, null, null, "Hello, world");

            var message = router.GetAndFinish("queue_A", out _);

            Assert.That(message, Is.EqualTo("Hello, world"));
        }