public void FudgePackerRecursivelyPackTlvs() { var packable = new TlvPackable(0xfe, 0x1234, 0x23456789); var recursivePackable = new RecursiveTlvPackable(0xab, 0x2468, packable, 0x13579bdf); var serialisedData = new byte[] { 0xab, 0x24, 0x68, 0xad, 0x00, 0x07, 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89, 0x13, 0x57, 0x9b, 0xdf, }; Assert.Equal(serialisedData, FudgeFactory.Packer(typeof(RecursiveTlvPackable)).Pack(recursivePackable).ToArray()); }
public void FudgePackerRecursivelyUnpackTlvs() { var packable = new TlvPackable(0xfe, 0x1234, 0x23456789); var recursivePackable = new RecursiveTlvPackable(0xab, 0x2468, packable, 0x13579bdf); var serialisedData = new byte[] { 0xab, 0x24, 0x68, 0xad, 0x00, 0x07, 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89, 0x13, 0x57, 0x9b, 0xdf, }; using (var stream = new MemoryStream(serialisedData)) { Assert.Equal(recursivePackable, FudgeFactory.Packer(typeof(RecursiveTlvPackable)).Unpack(typeof(RecursiveTlvPackable), stream)); } }