Exemplo n.º 1
0
        public void FudgePackerRecursivelyPackFields()
        {
            var packable          = new Packable(0xfe, 0x1234, 0x23456789);
            var recursivePackable = new RecursivePackable(0xab, 0x2468, packable, 0x13579bdf);
            var serialisedData    = new byte[] {
                0xab,
                0x24, 0x68,
                0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89,
                0x13, 0x57, 0x9b, 0xdf,
            };

            Assert.Equal(serialisedData, FudgeFactory.Packer(typeof(RecursivePackable)).Pack(recursivePackable).ToArray());
        }
Exemplo n.º 2
0
        public void FudgePackerRecursivelyUnpackFields()
        {
            var packable          = new Packable(0xfe, 0x1234, 0x23456789);
            var recursivePackable = new RecursivePackable(0xab, 0x2468, packable, 0x13579bdf);
            var serialisedData    = new byte[] {
                0xab,
                0x24, 0x68,
                0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89,
                0x13, 0x57, 0x9b, 0xdf,
            };

            using (var stream = new MemoryStream(serialisedData))
            {
                Assert.Equal(recursivePackable, FudgeFactory.Packer(typeof(RecursivePackable)).Unpack(typeof(RecursivePackable), stream));
            }
        }