示例#1
0
        public async Task Encode_DecodeRoundtrip_ReturnsInput(ulong input)
        {
            var pipe = new Pipe();
            await VarUInt.Encode(input, pipe.Writer);

            Assert.That(VarUInt.Decode(pipe.Reader), Is.EqualTo(input));
        }
示例#2
0
        public async Task <byte[]> Encode_ValidInput_ReturnsCorrectValue(ulong input)
        {
            var stream = new MemoryStream();
            var writer = PipeWriter.Create(stream);
            await VarUInt.Encode(input, writer);

            return(stream.ToArray());
        }
示例#3
0
        private static void InitCustomDataNode()
        {
            VarBool isBind = new VarBool(false);

            DataNode.SetData(Constant.DataNode.IsWXBind, isBind);
            VarString v_userId = new VarString("");

            DataNode.SetData(Constant.DataNode.UserId, v_userId);
            VarUInt v_score = new VarUInt(0);

            DataNode.SetData(Constant.DataNode.UserScore, v_score);
        }
示例#4
0
        protected override void OnDead(Entity attacker)
        {
            base.OnDead(attacker);

            GameData.g_listAsteroid.Remove(this);

            GameEntry.Entity.ShowEffect(new EffectData(GameEntry.Entity.GenerateSerialId(), 1)
            {
                Position = CachedTransform.localPosition,
            });
            GameEntry.Sound.PlaySound("explosion_asteroid");

            VarUInt v_score = GameEntry.DataNode.GetData <VarUInt>(Constant.DataNode.UserScore);

            v_score++;
            GameEntry.DataNode.SetData <VarUInt>(Constant.DataNode.UserScore, v_score);
        }
示例#5
0
        public void Decode_MissingFollowup_Throws()
        {
            var stream = PipeReader.Create(new MemoryStream(new byte[] { 172 }));

            Assert.That(() => VarUInt.Decode(stream), Throws.Exception);
        }
示例#6
0
        public ulong Decode_FullInput_ReturnsCorrectValue(byte[] input)
        {
            var str = PipeReader.Create(new MemoryStream(input));

            return(VarUInt.Decode(str));
        }