UnpackArray() public static method

Unpacks the array value from the specified Stream.

The processed bytes count can be calculated via P:Stream.Position of source when the P:Stream.CanSeek is true.

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

/// is null. /// /// The of is false. /// /// is not valid MessagePack stream. /// Note that the state of will be unpredictable espicially it is not seekable. /// /// The unpacked result in the is not compatible to . /// Note that the state of will be unpredictable espicially it is not seekable. /// /// The items count of the underlying collection body is over . ///
public static UnpackArray ( Stream source ) : IList
source Stream The which contains Message Pack binary stream.
return IList
コード例 #1
0
        public void TestUnpackArray_ByteArray_FixArray0Value_AsFixArray0_AsIs()
        {
            var result = Unpacking.UnpackArray(new byte[] { 0x90 });

            Assert.AreEqual(1, result.ReadCount);
            Assert.That(result.Value, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0).ToArray()));
        }
コード例 #2
0
        public void TestUnpackArray_ByteArray_Null_Nil()
        {
            var result = Unpacking.UnpackArray(new byte[] { 0xC0 });

            Assert.AreEqual(1, result.ReadCount);
            Assert.IsNull(result.Value);
        }
コード例 #3
0
        public void TestUnpackArray_ByteArray_Array32MinValue_AsArray32_AsIs()
        {
            var result = Unpacking.UnpackArray(new byte[] { 0xDD, 0x00, 0x01, 0x00, 0x00 }.Concat(Enumerable.Repeat(( byte )0x57, 0x10000)).ToArray());

            Assert.AreEqual(65541, result.ReadCount);
            Assert.That(result.Value, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0x10000).ToArray()));
        }
コード例 #4
0
        public void TestUnpackArray_ByteArray_Array16MaxValue_AsArray16_AsIs()
        {
            var result = Unpacking.UnpackArray(new byte[] { 0xDC, 0xFF, 0xFF }.Concat(Enumerable.Repeat(( byte )0x57, 0xFFFF)).ToArray());

            Assert.AreEqual(65538, result.ReadCount);
            Assert.That(result.Value, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0xFFFF).ToArray()));
        }
コード例 #5
0
        public void TestUnpackArray_ByteArray_FixArray1Value_AsFixArray1_AsIs()
        {
            var result = Unpacking.UnpackArray(new byte[] { 0x91 }.Concat(Enumerable.Repeat(( byte )0x57, 1)).ToArray());

            Assert.AreEqual(2, result.ReadCount);
            Assert.That(result.Value, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 1).ToArray()));
        }
コード例 #6
0
 public void TestUnpackArray_Stream_FixArray0Value_AsFixArray0_AsIs()
 {
     using (var buffer = new MemoryStream(new byte[] { 0x90 }))
     {
         var result = Unpacking.UnpackArray(buffer);
         Assert.AreEqual(1, buffer.Position);
         Assert.That(result, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0).ToArray()));
     }
 }
コード例 #7
0
 public void TestUnpackArray_Stream_Array32MinValue_AsArray32_AsIs()
 {
     using (var buffer = new MemoryStream(new byte[] { 0xDD, 0x00, 0x01, 0x00, 0x00 }.Concat(Enumerable.Repeat(( byte )0x57, 0x10000)).ToArray()))
     {
         var result = Unpacking.UnpackArray(buffer);
         Assert.AreEqual(65541, buffer.Position);
         Assert.That(result, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0x10000).ToArray()));
     }
 }
コード例 #8
0
 public void TestUnpackArray_Stream_Array16MaxValue_AsArray16_AsIs()
 {
     using (var buffer = new MemoryStream(new byte[] { 0xDC, 0xFF, 0xFF }.Concat(Enumerable.Repeat(( byte )0x57, 0xFFFF)).ToArray()))
     {
         var result = Unpacking.UnpackArray(buffer);
         Assert.AreEqual(65538, buffer.Position);
         Assert.That(result, Is.EqualTo(Enumerable.Repeat(new MessagePackObject(0x57), 0xFFFF).ToArray()));
     }
 }
コード例 #9
0
 public void TestUnpackArray_Eof()
 {
     Assert.Throws <UnpackException>(() => Unpacking.UnpackArray(new byte[] { 0x91 }));
 }
コード例 #10
0
 public void TestUnpackArray_ArrayLengthIsGreaterThanInt32MaxValue()
 {
     Assert.Throws <MessageNotSupportedException>(() => Unpacking.UnpackArray(new byte[] { 0xDD, 0x80, 0x00, 0x00, 0x00, 0xFF }));
 }
コード例 #11
0
 public void TestUnpackArray_ByteArray_NotArray()
 {
     Assert.Throws <MessageTypeException>(() => Unpacking.UnpackArray(new byte[] { 0x1 }));
 }