public void ToMessage()
        {
            var converter = new NewtonJsonMessageConverter();
            var payload   = new MyBean
            {
                String   = "Foo",
                Number   = 42,
                Fraction = 42F,
                Array    = new string[] { "Foo", "Bar" },
                Bool     = true,
                Bytes    = new byte[] { 0x1, 0x2 }
            };

            var message = converter.ToMessage(payload, null);

            var actual = Encoding.UTF8.GetString((byte[])message.Payload);

            Assert.Contains("\"string\":\"Foo\"", actual);
            Assert.Contains("\"number\":42", actual);
            Assert.Contains("\"fraction\":42.0", actual);
            Assert.Contains("\"array\":[\"Foo\",\"Bar\"]", actual);
            Assert.Contains("\"bool\":true", actual);
            Assert.Contains("\"bytes\":\"AQI=\"", actual);
            Assert.Equal(new MimeType("application", "json", Encoding.UTF8), message.Headers[MessageHeaders.CONTENT_TYPE]);
        }
        public void ToMessageUtf16String()
        {
            var converter = new NewtonJsonMessageConverter();

            converter.SerializedPayloadClass = typeof(string);
            var encoding    = new UnicodeEncoding(true, false);
            var contentType = new MimeType("application", "json", encoding);
            IDictionary <string, object> map = new Dictionary <string, object>();

            map.Add(MessageHeaders.CONTENT_TYPE, contentType);
            var headers = new MessageHeaders(map);
            var payload = "H\u00e9llo W\u00f6rld";
            var message = converter.ToMessage(payload, headers);

            Assert.Equal("\"" + payload + "\"", message.Payload);
            Assert.Equal(contentType, message.Headers[MessageHeaders.CONTENT_TYPE]);
        }
        public void ToMessageUtf16()
        {
            var e           = Encoding.Default;
            var converter   = new NewtonJsonMessageConverter();
            var encoding    = new UnicodeEncoding(true, false);
            var contentType = new MimeType("application", "json", encoding);
            IDictionary <string, object> map = new Dictionary <string, object>();

            map.Add(MessageHeaders.CONTENT_TYPE, contentType);
            var headers  = new MessageHeaders(map);
            var payload  = "H\u00e9llo W\u00f6rld";
            var message  = converter.ToMessage(payload, headers);
            var actual   = encoding.GetString((byte[])message.Payload);
            var expected = "\"" + payload + "\"";

            Assert.Equal(expected, actual);
            Assert.Equal(contentType, message.Headers[MessageHeaders.CONTENT_TYPE]);
        }