コード例 #1
0
        public void Test_ToUInt64_NoNboSpecified(byte[] bytes, ulong expected)
        {
            var converter = new DefaultConverter();
            var actual    = converter.ToUInt64(bytes.AsSpan());

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void Test_ToUInt64(byte[] bytes, ulong expected, bool useNbo)
        {
            var converter = new DefaultConverter();
            var actual    = converter.ToUInt64(bytes.AsSpan(), useNbo);

            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public void Test_Cas()
        {
            var         converter = new DefaultConverter();
            var         bytes     = new byte[] { 255, 255, 255, 255, 229, 93, 159, 223 };
            const ulong expected  = 18446744073262702559;
            var         actual    = converter.ToUInt64(bytes, 0);

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void Test_Cas2()
        {
            var converter = new DefaultConverter();
            var bytes     = new byte[]
            {
                0x00,
                0x00,
                0xa9,
                0x53,
                0x5f,
                0x3d,
                0xa7,
                0x0f
            };
            const ulong expected = 186175545255695;
            var         actual   = converter.ToUInt64(bytes, 0);

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        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);
        }