public RecursiveTlvPackable(byte i8, ushort i16, TlvPackable tlvPackable, uint i32) { this.i8 = i8; this.i16 = i16; this.i32 = i32; this.tlvPackable = tlvPackable; }
public void FudgePackerPackTlvs() { var packable = new TlvPackable(0xfe, 0x1234, 0x23456789); var serialisedData = new byte[] { 0xad, 0x00, 0x07, 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89, }; Assert.Equal(serialisedData, FudgeFactory.Packer(typeof(TlvPackable)).Pack(packable).ToArray()); }
public void FudgePackerUnpackTlvs() { var packable = new TlvPackable(0xfe, 0x1234, 0x23456789); var serialisedData = new byte[] { 0xad, 0x00, 0x07, 0xfe, 0x12, 0x34, 0x23, 0x45, 0x67, 0x89, }; using (var stream = new MemoryStream(serialisedData)) { Assert.Equal(packable, FudgeFactory.Packer(typeof(TlvPackable)).Unpack(typeof(TlvPackable), stream)); } }
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)); } }