예제 #1
0
        /// <summary>Check that an Cue round-trips through serialization cleanly</summary>
        public void RoundTripCheck()
        {
            // Serialize a first time
            MemoryStream        firstMemoryStream     = new MemoryStream();
            CueSerializeContext firstSerializeContext = new CueSerializeContext(new BinaryWriter(firstMemoryStream));

            Serialize(firstSerializeContext);
            byte[] originalData = firstMemoryStream.ToArray();

            // Then deserialize that data
            BinaryReader          br = new BinaryReader(new MemoryStream(originalData));
            CueDeserializeContext deserializeContext = new CueDeserializeContext(br);
            Cue deserialized = new Cue(deserializeContext);

            // Then serialize that deserialized data and see if it matches
            MemoryCompareStream secondMemoryStream     = new MemoryCompareStream(originalData);
            CueSerializeContext secondSerializeContext = new CueSerializeContext(new BinaryWriter(secondMemoryStream));

            deserialized.Serialize(secondSerializeContext);
        }