UnpackNull() public static method

Unpacks the nil from the head of specified byte array.

Invocation of this method is equivalant to call UnpackNull(byte[], int) with offset is 0.

When the type of packed value is not known, use UnpackObject(byte[]) instead.

/// is null. /// /// is empty. /// /// is not valid MessagePack stream. /// /// The unpacked result in the is not compatible to . ///
public static UnpackNull ( byte source ) : UnpackingResult
source byte The byte array which contains Message Pack binary stream.
return UnpackingResult
Esempio n. 1
0
 public void TestUnpackNull_Stream_False()
 {
     using (var buffer = new MemoryStream(new byte[] { 0xC2 }))
     {
         Assert.Throws <MessageTypeException>(() => Unpacking.UnpackNull(buffer));
     }
 }
Esempio n. 2
0
        public void TestUnpackNull_ByteArray_AsIs()
        {
            var result = Unpacking.UnpackNull(new byte[] { 0xC0 });

            Assert.AreEqual(1, result.ReadCount);
            Assert.IsNull(result.Value);
        }
Esempio n. 3
0
        public void TestUnpackNull_ByteArray_Offset_OffsetIsValid_OffsetIsRespected()
        {
            var result = Unpacking.UnpackNull(new byte[] { 0xFF, 0xC0, 0xFF }, 1);

            Assert.AreEqual(1, result.ReadCount);
            Assert.IsNull(result.Value);
        }
Esempio n. 4
0
        public void TestNil()
        {
            var output = new MemoryStream();

            Packer.Create(output).PackNull();
            Assert.AreEqual(null, Unpacking.UnpackNull(new MemoryStream(output.ToArray())));
            Assert.AreEqual(null, Unpacking.UnpackNull(output.ToArray()).Value);
        }
Esempio n. 5
0
 public void TestUnpackNull_Stream_Nil_AsIs()
 {
     using (var buffer = new MemoryStream(new byte[] { 0xC0 }))
     {
         var result = Unpacking.UnpackNull(buffer);
         Assert.AreEqual(1, buffer.Position);
         Assert.IsNull(result);
     }
 }
Esempio n. 6
0
 public void TestUnpackNull_ByteArray_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackNull(default(byte[])));
 }
Esempio n. 7
0
 public void TestUnpackNull_ByteArray_Empty()
 {
     Assert.Throws <ArgumentException>(() => Unpacking.UnpackNull(new byte[0]));
 }
Esempio n. 8
0
 public void TestUnpackNull_ByteArray_False()
 {
     Assert.Throws <MessageTypeException>(() => Unpacking.UnpackNull(new byte[] { 0xC2 }));
 }
Esempio n. 9
0
 public void TestUnpackNull_Stream_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackNull(default(Stream)));
 }
Esempio n. 10
0
 public void TestUnpackNull_ByteArray_Offset_OffsetIsTooBig()
 {
     Assert.Throws <ArgumentException>(() => Unpacking.UnpackNull(new byte[] { 0x1 }, 1));
 }
Esempio n. 11
0
 public void TestUnpackNull_ByteArray_Offset_OffsetIsNegative()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Unpacking.UnpackNull(new byte[] { 0x1 }, -1));
 }