public void Test_GetWithValue()
        {
            var packet = new byte[]
            {
                129, 187, 0, 0, 12, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 45, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, 0, 34
            };

            var response = MemoryPool <byte> .Shared.RentAndSlice(packet.Length);

            packet.AsMemory(0, packet.Length).CopyTo(response.Memory);
            var op = new GetCid();

            op.Read(response);

            var result = op.GetResultWithValue();

            Assert.True(result.Content.HasValue);
            Assert.Equal(85u, result.Content.Value);
        }
示例#2
0
        public void Test_GetCid_GetValue_Throws_NotImplementedException()
        {
            var packet = new byte[]
            {
                0x18, 0xbb, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1a,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x17
            };

            var response = MemoryPool <byte> .Shared.RentAndSlice(packet.Length);

            packet.AsMemory(0, packet.Length).CopyTo(response.Memory);
            var op = new GetCid()
            {
                Transcoder = new LegacyTranscoder()
            };

            op.Read(response);

            Assert.Throws <NotImplementedException>(() => op.GetValue());
        }
        public void Test_GetWithValue()
        {
            var packet = new byte[]
            {
                0x18, 0xbb, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1a,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x17
            };

            var response = MemoryPool <byte> .Shared.RentAndSlice(packet.Length);

            packet.AsMemory(0, packet.Length).CopyTo(response.Memory);
            var op = new GetCid()
            {
                Transcoder = new LegacyTranscoder()
            };

            op.Read(response);

            var result = op.GetResultWithValue();

            Assert.True(result.Content.HasValue);
            Assert.Equal(0x17u, result.Content.Value);
        }