Ejemplo n.º 1
0
        public void FudgePackerPackFields()
        {
            var packable       = new Packable(0xfe, 0x1234, 0x23456789);
            var serialisedData = new byte[] { 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89 };

            Assert.Equal(serialisedData, FudgeFactory.Packer(typeof(Packable)).Pack(packable).ToArray());
        }
Ejemplo n.º 2
0
        public void FudgePackerUnpackFields()
        {
            var packable       = new Packable(0xfe, 0x1234, 0x23456789);
            var serialisedData = new byte[] { 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89 };

            using (var stream = new MemoryStream(serialisedData))
            {
                Assert.Equal(packable, FudgeFactory.Packer(typeof(Packable)).Unpack(typeof(Packable), stream));
            }
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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));
            }
        }