Beispiel #1
0
        public void TestIMessagePackSerializerUnpackTo_CollectionTypeIsInvalid()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            using (var buffer = new MemoryStream(new byte[] { 0x91, 0x1 }))
                using (var unpacker = Unpacker.Create(buffer))
                {
                    var collection = new bool[1];
                    Assert.Throws <ArgumentException>(() => target.UnpackTo(unpacker, collection));
                }
        }
Beispiel #2
0
        public void TestIMessagePackSerializerUnpackTo_CollectionIsNull()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            using (var buffer = new MemoryStream(new byte[] { 0x91, 0x1 }))
                using (var unpacker = Unpacker.Create(buffer))
                {
                    unpacker.Read();
                    Assert.Throws <ArgumentNullException>(() => target.UnpackTo(unpacker, null));
                }
        }
Beispiel #3
0
        public void TestIMessagePackSerializerUnpackTo_StreamContainsNull()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            using (var buffer = new MemoryStream(new byte[] { 0xC0 }))
                using (var unpacker = Unpacker.Create(buffer))
                {
                    unpacker.Read();
                    var collection = new int[0];
                    target.UnpackTo(unpacker, collection);
                }
        }
Beispiel #4
0
        public void TestIMessagePackSerializerUnpackTo_StreamContentIsInvalid()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            using (var buffer = new MemoryStream(new byte[] { 0x1 }))
                using (var unpacker = Unpacker.Create(buffer))
                {
                    unpacker.Read();
                    var collection = new int[1];
                    Assert.Throws <SerializationException>(() => target.UnpackTo(unpacker, collection));
                }
        }
Beispiel #5
0
        public void TestIMessagePackSerializerUnpackTo_Valid_Success()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            using (var buffer = new MemoryStream(new byte[] { 0x91, 0x1 }))
                using (var unpacker = Unpacker.Create(buffer))
                {
                    unpacker.Read();
                    var collection = new int[2];
                    target.UnpackTo(unpacker, collection);
                    // colection[1] is still 0.
                    Assert.That(collection, Is.EqualTo(new[] { 1, 0 }));
                }
        }
Beispiel #6
0
        public void TestIMessagePackSerializerUnpackTo_UnpackerIsNull()
        {
            IMessagePackSerializer target = CreateTarget <int[]>();

            Assert.Throws <ArgumentNullException>(() => target.UnpackTo(null, new int[1]));
        }