Esempio n. 1
0
        public void Registry_ElementAlreadyRegisteredException()
        {
            var tested = new BlockDataPoolRegistry();

            tested.Register(0, () => null);

            Assert.Throws <ElementAlreadyRegisteredException>(() => tested.Register(0, () => null));
        }
Esempio n. 2
0
        public void Serialization_WriteAndReadChunk()
        {
            const ushort location = 7, value = 58;
            const byte   b = 0xFE;

            var blockDataPoolingRegistry = new BlockDataPoolRegistry();

            blockDataPoolingRegistry.Register(value, () => new MockBlockData());

            var chunkState1 = new ChunkState();
            var chunkState2 = new ChunkState();

            var blockData = chunkState1.SetBlock(location, value, blockDataPoolingRegistry) as MockBlockData;

            blockData.theByte = b;

            var buffer = new ResizableByteBuffer();

            buffer.RestartForWriting();
            chunkState1.Serialize(buffer);

            buffer.RestartForReading();
            chunkState2.Deserialize(buffer, blockDataPoolingRegistry);

            var resultId       = chunkState2.GetBlockID(location);
            var resultData     = (MockBlockData)chunkState2.GetBlockData(location);
            var resultDataByte = resultData.theByte;

            Assert.AreEqual(value, resultId);
            Assert.AreEqual(b, resultDataByte);
        }