public async Task ConvertAsync_ReturnsExpectedResult_WithSerializedString(string contentType, string value)
        {
            BrokeredMessage message = new BrokeredMessage(value);

            message.ContentType = contentType;

            BrokeredMessageToStringConverter converter = new BrokeredMessageToStringConverter();
            string result = await converter.ConvertAsync(message, CancellationToken.None);

            Assert.Equal(value, result);
        }
        public async Task ConvertAsync_ReturnsExpectedResult(string contentType, string value)
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            sw.Write(value);
            sw.Flush();
            ms.Seek(0, SeekOrigin.Begin);

            BrokeredMessage message = new BrokeredMessage(ms);
            message.ContentType = contentType;

            BrokeredMessageToStringConverter converter = new BrokeredMessageToStringConverter();
            string result = await converter.ConvertAsync(message, CancellationToken.None);

            Assert.Equal(value, result);
        }
        public async Task ConvertAsync_ReturnsExpectedResult_WithStream(string contentType, string value)
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);

            sw.Write(value);
            sw.Flush();
            ms.Seek(0, SeekOrigin.Begin);

            BrokeredMessage message = new BrokeredMessage(ms);

            message.ContentType = contentType;

            BrokeredMessageToStringConverter converter = new BrokeredMessageToStringConverter();
            string result = await converter.ConvertAsync(message, CancellationToken.None);

            Assert.Equal(value, result);
        }
        public async Task ConvertAsync_Throws_WithSerializedObject()
        {
            BrokeredMessage message = new BrokeredMessage(new TestObject {
                Text = TestString
            });

            BrokeredMessageToStringConverter converter = new BrokeredMessageToStringConverter();
            var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => converter.ConvertAsync(message, CancellationToken.None));

            Assert.IsType <SerializationException>(exception.InnerException);
            Assert.StartsWith("The BrokeredMessage with ContentType 'null' failed to deserialize to a string with the message:", exception.Message);
        }