示例#1
0
        public void InstructionTest(int opcode, int param)
        {
            // encode & decode
            var instruction = new FieldScriptInstruction(opcode, param);

            if (param == -1)
            {
                instruction = new FieldScriptInstruction(opcode);
            }
            instruction = new FieldScriptInstruction(BitConverter.GetBytes(instruction.Encode()));

            // make sure nothing's changed
            Assert.Equal(opcode, instruction.OpCode);
            if (param == -1)
            {
                Assert.False(instruction.HasParam);
            }
            else
            {
                Assert.True(instruction.HasParam);
                Assert.Equal(param, instruction.Param);
            }
        }
示例#2
0
        public void EntityTest(int label, EntityType type)
        {
            // construct a simple entity
            var labelInstr = new FieldScriptInstruction(5, label);
            var script     = new Script(new List <FieldScriptInstruction>()
            {
                labelInstr
            }, false);
            var entity = new Entity(type, new List <Script>()
            {
                script
            });

            // extract info, then encode & decode
            var entityInfo = new EntityInfo(entity);

            entityInfo = new EntityInfo(entity.Type, entityInfo.Encode());

            // info reflects the original entity
            Assert.Equal(label, entityInfo.Label);
            Assert.Equal(type, entityInfo.Type);
            Assert.Equal(0, entityInfo.ScriptCount);
        }