public void DeserializeNonIndexedArray()
        {
            // given
            var data = Hex.EightByteNonIndexedArray;

            // when
            var value = VPack.ToObject <List <object> >(data);

            // then
            // array
            Assert.IsInstanceOf <List <object> >(value);
            Assert.AreEqual(3, value.Count);

            // first item
            var item1 = value[0];

            Assert.IsInstanceOf <sbyte>(item1);
            Assert.AreEqual(1, item1);

            // second item
            var item2 = value[1];

            Assert.IsInstanceOf <sbyte>(item2);
            Assert.AreEqual(2, item2);

            // third item
            var item3 = value[2];

            Assert.IsInstanceOf <sbyte>(item3);
            Assert.AreEqual(3, item3);
        }
コード例 #2
0
        public void DeserializeCompactArray()
        {
            // TODO: cast to List<sbyte>

            // given
            var data = Converter.ToVPackBytes(Paths.JsonCompactArray, true, false);

            // when
            var value = VPack.ToObject <List <object> >(data);

            // then
            // array
            Assert.IsInstanceOf <List <object> >(value);
            Assert.AreEqual(3, value.Count);

            // first item
            var item1 = value[0];

            Assert.IsInstanceOf <sbyte>(item1);
            Assert.AreEqual(1, item1);

            // second item
            var item2 = value[1];

            Assert.IsInstanceOf <sbyte>(item2);
            Assert.AreEqual(2, item2);

            // third item
            var item3 = value[2];

            Assert.IsInstanceOf <sbyte>(item3);
            Assert.AreEqual(3, item3);
        }
コード例 #3
0
        public void DeserializeNullValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonNullValue);

            // when
            var value = VPack.ToObject <object>(data);

            // then
            Assert.IsNull(value);
        }
        public void DeserializeEightByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonEightByteUnsignedInt);

            // when
            var value = VPack.ToObject <ulong>(data);

            // then
            Assert.AreEqual(18446744073709551615, value);
        }
コード例 #5
0
        public void DeserializeOneByteSignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonOneByteSignedInt);

            // when
            var value = VPack.ToObject <sbyte>(data);

            // then
            Assert.AreEqual((sbyte)-12, value);
        }
コード例 #6
0
        public void DeserializeSevenByteSignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonSevenByteSignedInt);

            // when
            var value = VPack.ToObject <long>(data);

            // then
            Assert.AreEqual(-1234567890123456, value);
        }
コード例 #7
0
        public void DeserializeTwoByteSignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonTwoByteSignedInt);

            // when
            var value = VPack.ToObject <short>(data);

            // then
            Assert.AreEqual((short)-12345, value);
        }
        public void DeserializeSevenByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonSevenByteUnsignedInt);

            // when
            var value = VPack.ToObject <ulong>(data);

            // then
            Assert.AreEqual((ulong)72057594037927935, value);
        }
        public void DeserializeSixByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonSixByteUnsignedInt);

            // when
            var value = VPack.ToObject <ulong>(data);

            // then
            Assert.AreEqual((ulong)281474976710655, value);
        }
        public void DeserializeFiveByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonFiveByteUnsignedInt);

            // when
            var value = VPack.ToObject <ulong>(data);

            // then
            Assert.AreEqual((ulong)1099511627775, value);
        }
        public void DeserializeFourByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonFourByteUnsignedInt);

            // when
            var value = VPack.ToObject <uint>(data);

            // then
            Assert.AreEqual(4294967295, value);
        }
        public void DeserializeThreeByteUnsignedIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonThreeByteUnsignedInt);

            // when
            var value = VPack.ToObject <uint>(data);

            // then
            Assert.AreEqual((uint)16777215, value);
        }
コード例 #13
0
        public void DeserializeDoubleValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonDouble);

            // when
            var value = VPack.ToObject <double>(data);

            // then
            Assert.AreEqual(0.33333333333333331, value);
        }
コード例 #14
0
        public void DeserializePosOneByteFloatValue()
        {
            // given
            var data = Hex.PosOneByteLengthFloatValue;

            // when
            var value = VPack.ToObject <float>(data);

            // then
            Assert.AreEqual((float)12345, value);
        }
コード例 #15
0
        public void DeserializeMinKeyValue()
        {
            // given
            var data = Hex.MinKeyValue;

            // when
            var value = VPack.ToObject <object>(data);

            // then
            Assert.IsNull(value);
        }
コード例 #16
0
        public void DeserializeNoneValue()
        {
            // given
            var data = new byte[] { 0x00 };

            // when
            var value = VPack.ToObject <object>(data);

            // then
            Assert.IsNull(value);
        }
コード例 #17
0
        public void DeserializeZeroIntValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonZeroInt);

            // when
            var value = VPack.ToObject <sbyte>(data);

            // then
            Assert.AreEqual(0, value);
        }
コード例 #18
0
        public void DeserializeFalseBooleanValue()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonFalseValue);

            // when
            var value = VPack.ToObject <bool>(data);

            // then
            Assert.IsFalse(value);
        }
コード例 #19
0
        public void DeserializeEmptyArray()
        {
            // given
            var data = Converter.ToVPackBytes(Paths.JsonEmptyArray);

            // when
            var value = VPack.ToObject <List <object> >(data);

            // then
            Assert.IsInstanceOf <List <object> >(value);
            Assert.AreEqual(0, value.Count);
        }
コード例 #20
0
        public void DeserializeNonIndexedArray_With_FourZeroByteByteLengthSize()
        {
            // given
            var data = Hex.FourByteNonIndexedArrayWithFourZeroBytes;

            // when
            var value = VPack.ToObject <List <object> >(data);

            // then
            // array
            Assert.IsInstanceOf <List <object> >(value);
            Assert.AreEqual(3, value.Count);

            TestSmallIntegerItems(value);
        }