public void ReadLengthFailsUnexpectedEnd(byte[] input) { var ms = new MemoryStream(input); Assert.ThrowsException <TlvException>(() => { TlvEncoding.ReadLength(ms); }); }
public void ReadLengthFails5Bytes() { var ms = new MemoryStream(new byte[] { 0x85, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }); Assert.ThrowsException <TlvException>(() => { TlvEncoding.ReadLength(ms); }); }
//[DataRow(new byte[] { 0x84, 0xAB, 0xCD, 0xEF, 0x01, 0x01 }, 0xABCDEF01, 5, DisplayName = "1000 0100 1010 1011 1100 1101 1110 1111 0000 0001")] public void ReadLengthSuccess(byte[] input, int?expectedLength, int expectedPosition) { var ms = new MemoryStream(input); var t = TlvEncoding.ReadLength(ms); Assert.AreEqual(expectedLength, t); Assert.AreEqual(expectedPosition, ms.Position); }