public void Test_ToInt64(byte[] bytes, long expected, bool useNbo) { var converter = new DefaultConverter(); var actual = converter.ToInt64(bytes.AsSpan(), useNbo); Assert.Equal(expected, actual); }
public void Test_ToInt64_NoNboSpecified(byte[] bytes, long expected) { var converter = new DefaultConverter(); var actual = converter.ToInt64(bytes.AsSpan()); Assert.Equal(expected, actual); }
public void Test_ObserveSeqno_Parse_Packet() { var converter = new DefaultConverter(); var packet = new byte [] { 0x81, //magic 0x01, //opcode 0x00, 0x00, //key length 0x10, //extra length 0x00, //data type 0x00, 0x00, //status 0x00, 0x00, 0x00, 0x10, //total body 0x00, 0x00, 0x00, 0x01, //opaque 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //cas 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x39, //uuid 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D //seqno }; var extras = new byte[converter.ToByte(packet, HeaderIndexFor.ExtrasLength)]; var uuid = converter.ToUInt64(packet, 24); var seqno = converter.ToInt64(packet, 32); Assert.AreEqual(12345, uuid); Assert.AreEqual(45, seqno); }