Ejemplo n.º 1
0
        public void TestSerialize()
        {
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);
            BinaryReader reader = new BinaryReader(stream);

            writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x01 });
            stream.Seek(0, SeekOrigin.Begin);
            UInt32Wrapper temp = new UInt32Wrapper();

            temp.Deserialize(reader);
            MemoryStream stream2 = new MemoryStream();
            BinaryWriter writer2 = new BinaryWriter(stream2);

            temp.Serialize(writer2);
            stream2.Seek(0, SeekOrigin.Begin);
            byte[] byteArray = new byte[stream2.Length];
            stream2.Read(byteArray, 0, (int)stream2.Length);
            Assert.AreEqual(Encoding.Default.GetString(new byte[] { 0x00, 0x00, 0x00, 0x01 }), Encoding.Default.GetString(byteArray));
        }