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
Ejemplo n.º 1
0
 public void TestUnpackNull_Stream_False()
 {
     using (var buffer = new MemoryStream(new byte[] { 0xC2 }))
     {
         Assert.Throws <MessageTypeException>(() => Unpacking.UnpackNull(buffer));
     }
 }
Ejemplo n.º 2
0
        public void TestUnpackNull_ByteArray_AsIs()
        {
            var result = Unpacking.UnpackNull(new byte[] { 0xC0 });

            Assert.AreEqual(1, result.ReadCount);
            Assert.IsNull(result.Value);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
     }
 }
Ejemplo n.º 6
0
 public void TestUnpackNull_ByteArray_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackNull(default(byte[])));
 }
Ejemplo n.º 7
0
 public void TestUnpackNull_ByteArray_Empty()
 {
     Assert.Throws <ArgumentException>(() => Unpacking.UnpackNull(new byte[0]));
 }
Ejemplo n.º 8
0
 public void TestUnpackNull_ByteArray_False()
 {
     Assert.Throws <MessageTypeException>(() => Unpacking.UnpackNull(new byte[] { 0xC2 }));
 }
Ejemplo n.º 9
0
 public void TestUnpackNull_Stream_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackNull(default(Stream)));
 }
Ejemplo n.º 10
0
 public void TestUnpackNull_ByteArray_Offset_OffsetIsTooBig()
 {
     Assert.Throws <ArgumentException>(() => Unpacking.UnpackNull(new byte[] { 0x1 }, 1));
 }
Ejemplo n.º 11
0
 public void TestUnpackNull_ByteArray_Offset_OffsetIsNegative()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Unpacking.UnpackNull(new byte[] { 0x1 }, -1));
 }