public void Serialization(object obj, ISerializer serializer) { var resp = obj == null ? new ResponsePacket() : new ResponsePacket(obj); using (var ms = new MemoryStream()) using (var writer = new BinaryWriter(ms, Encoding.Default, true)) using (var reader = new BinaryReader(ms, Encoding.Default, true)) { resp.Serialize(writer, serializer); ms.Position = 0; var r2 = new ResponsePacket(); r2.Deserialize(reader, serializer); Assert.AreEqual(resp.Data, r2.Data); } }