/// <summary>
        /// Asserts that a stream which is first deserialized by a context reader and then serialized
        /// with a context writer is byte-wise identical to the raw input stream.
        /// </summary>
        private static void AssertIdenticalSerialization(Stream rawContext)
        {
            using (rawContext)
            using (var msOut = new MemoryStream())
            using (var reader = new BizTalkContextReader(rawContext))
            using (var writer = new BizTalkContextWriter(msOut))
            {
                var properties = reader.ReadContextProperties().ToList();

                writer.WriteContext(properties);

                rawContext.Seek(0, SeekOrigin.Begin);
                msOut.Seek(0, SeekOrigin.Begin);

                Assert.AreEqual(rawContext.Length, msOut.Length);

                for (int i = 0; i < rawContext.Length; i++)
                {
                    var expected = rawContext.ReadByte();
                    var actual = msOut.ReadByte();
                    Assert.AreEqual(expected, actual, "Mismatch at offset 0x{0:X2}, expected 0x{1:X2}, actual 0x{2:X2}", i, expected, actual);
                }
            }
        }
        /// <summary>
        /// Asserts that a stream which is first deserialized by a context reader and then serialized
        /// with a context writer is byte-wise identical to the raw input stream.
        /// </summary>
        private static void AssertIdenticalSerialization(Stream rawContext)
        {
            using (rawContext)
                using (var msOut = new MemoryStream())
                    using (var reader = new BizTalkContextReader(rawContext))
                        using (var writer = new BizTalkContextWriter(msOut))
                        {
                            var properties = reader.ReadContextProperties().ToList();

                            writer.WriteContext(properties);

                            rawContext.Seek(0, SeekOrigin.Begin);
                            msOut.Seek(0, SeekOrigin.Begin);

                            Assert.AreEqual(rawContext.Length, msOut.Length);

                            for (int i = 0; i < rawContext.Length; i++)
                            {
                                var expected = rawContext.ReadByte();
                                var actual   = msOut.ReadByte();
                                Assert.AreEqual(expected, actual, "Mismatch at offset 0x{0:X2}, expected 0x{1:X2}, actual 0x{2:X2}", i, expected, actual);
                            }
                        }
        }