public void AddElementsToBodyTest()
        {
            Message message = MessageUtilityTests.GetSampleMessage();
            List <KeyValuePair <string, string> > queryOptions = MessageUtilityTests.GetSampleQueryOptions();

            MessageUtility.AddMessageQueryOptions(ref message, queryOptions);
            MessageUtilityTests.CompareSampleMessage(message);
        }
        public void BodyWriter_UnitTests()
        {
            Message originalMessage = MessageUtilityTests.GetSampleMessage();
            List <KeyValuePair <string, string> > queryOptions = MessageUtilityTests.GetSampleQueryOptions();
            Message newMessage = originalMessage;

            MessageUtility.AddMessageQueryOptions(ref newMessage, queryOptions);

            // messages are not the same
            Assert.AreNotEqual(originalMessage, newMessage);

            // headers are the same
            UnitTestHelper.AssertListsAreEqual <MessageHeaderInfo>(originalMessage.Headers, newMessage.Headers,
                                                                   (s, h) =>
            {
                return(s + ", " + h.Name);
            });

            // properties are the same
            // workaround for a strange property bug
            originalMessage.Properties.AllowOutputBatching = false;
            UnitTestHelper.AssertListsAreEqual <KeyValuePair <string, object> >(originalMessage.Properties, newMessage.Properties,
                                                                                (s, p) =>
            {
                return(s + ", " + p.ToString());
            });

            // version matches
            Assert.AreEqual(originalMessage.Version, newMessage.Version);

            // initial state check
            Assert.AreEqual(MessageState.Created, originalMessage.State);
            Assert.AreEqual(originalMessage.State, newMessage.State);

            // write message
            MessageUtilityTests.CompareSampleMessage(newMessage);

            // state, the original message should have been closed due to the write
            Assert.AreEqual(MessageState.Closed, originalMessage.State);

            // make sure to clean up
            newMessage.Close();
        }