public void BytesAsDefaultMessageBodyType()
        {
            var converter = new SimpleMessageConverter();
            var message   = new Message("test".ToByteArrayWithEncoding("UTF-8"), new MessageProperties());
            var result    = converter.FromMessage(message);

            Assert.AreEqual(typeof(byte[]), result.GetType());
            Assert.AreEqual("test", ((byte[])result).ToStringWithEncoding("UTF-8"));
        }
        public void MessageToString()
        {
            var converter = new SimpleMessageConverter();
            var message   = new Message("test".ToByteArrayWithEncoding("UTF-8"), new MessageProperties());

            message.MessageProperties.ContentType = MessageProperties.CONTENT_TYPE_TEXT_PLAIN;
            var result = converter.FromMessage(message);

            Assert.AreEqual(typeof(string), result.GetType());
            Assert.AreEqual("test", result);
        }
        public void MessageToBytes()
        {
            var converter = new SimpleMessageConverter();
            var message   = new Message(new byte[] { 1, 2, 3 }, new MessageProperties());

            message.MessageProperties.ContentType = MessageProperties.CONTENT_TYPE_BYTES;
            var result = converter.FromMessage(message);

            Assert.AreEqual(typeof(byte[]), result.GetType());
            var resultBytes = (byte[])result;

            Assert.AreEqual(3, resultBytes.Length);
            Assert.AreEqual(1, resultBytes[0]);
            Assert.AreEqual(2, resultBytes[1]);
            Assert.AreEqual(3, resultBytes[2]);
        }
        public void MessageToSerializedObject()
        {
            var converter  = new SimpleMessageConverter();
            var properties = new MessageProperties();

            properties.ContentType = MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT;
            var binaryFormatter = new BinaryFormatter();
            var byteStream      = new MemoryStream();
            var testObject      = new TestObject("foo");

            binaryFormatter.Serialize(byteStream, testObject);
            var bytes   = byteStream.ToArray();
            var message = new Message(bytes, properties);
            var result  = converter.FromMessage(message);

            Assert.AreEqual(typeof(TestObject), result.GetType());
            Assert.AreEqual(testObject, result);
        }