public void Serialize() { var packet = new MyPacket(); packet.foo = 14; packet.bar = 44; // TODO : endian var bytes = packet.Serialize(); byte[] expected = new byte[] { 14,0,0,0, 44,0,0,0 }; var offset = Marshal.SizeOf<Packet>(); for (var i = offset; i < bytes.Length; i++) { Console.Write(bytes[i].ToString() + " "); } Console.WriteLine(); for(var i = offset; i < bytes.Length; i++) { Assert.AreEqual( expected[i - offset], bytes[i]); } }