Exemple #1
0
        public int WriteTo(byte[] buffer, int offset)
        {
            var dataOffset = offset + MsgSerializer.HeaderLength;
            var written    = 0;

            written += MsgSerializer.WriteString(Game, buffer, dataOffset);
            written += MsgSerializer.WriteUInt16(Version, buffer, dataOffset + written);
            written += MsgSerializer.WriteString(PlayerName, buffer, dataOffset + written);
            written += MsgSerializer.WriteHeader(written, MsgId, buffer, offset);

            return(written);
        }
        public void ShouldSerializeAndDeserializeUInt16(ushort value)
        {
            var written = MsgSerializer.WriteUInt16(value, _buffer, 0);

            Assert.True(written == sizeof(ushort), $"Bad write size: {written}");

            var offset       = 0;
            var deserialized = MsgSerializer.ReadUInt16(_buffer, ref offset);

            Assert.True(offset == sizeof(ushort), $"Bad read size: {offset}");

            Assert.True(value == deserialized, $"Bad result: {deserialized}");
        }