示例#1
0
 public void SignedPrepareUnsupported()
 {
     Assert.Throws <UnsupportedDataTypeException>(() => {
         var coder = new HeliumIntegerSigned(0, false, 10);
         coder.Prepare(typeof(String));
     });
 }
示例#2
0
 public void SignedDecodeUnsupported()
 {
     Assert.Throws <UnsupportedDataTypeException>(() => {
         var coder = new HeliumIntegerSigned(0, false, 10);
         coder.Prepare(typeof(Int32));
         var decoded = coder.Decode(new DecodeBuffer(new Byte[] { 0, 0, 0 }));
     });
 }
示例#3
0
 public void SignedEncodeUnsupported()
 {
     Assert.Throws <UnsupportedDataTypeException>(() => {
         var coder = new HeliumIntegerSigned(0, false, 10);
         coder.Prepare(typeof(Int32));
         var encoded = coder.Encode("asdf");
     });
 }
示例#4
0
        public void SignedEncodeIncrement()
        {
            var coder = new HeliumIntegerSigned(0, false, 10);

            coder.Prepare(typeof(Int32));
            var encoded = coder.Encode((Int32)111);

            Assert.Equal("0B", encoded.ToHexString());
        }
示例#5
0
        public void SignedEncodeNullableNull()
        {
            var coder = new HeliumIntegerSigned(0, true, 1);

            coder.Prepare(typeof(Int32?));
            var encoded = coder.Encode(null);

            Assert.Equal(SignedVlq.Encode(0).ToHexString(), encoded.ToHexString());
        }
示例#6
0
        public void SignedEncodeNullableMin()
        {
            var coder = new HeliumIntegerSigned(0, true, 1);

            coder.Prepare(typeof(Int32));
            var encoded = coder.Encode(SignedVlq.MinValue + 1);

            Assert.Equal(SignedVlq.Encode(SignedVlq.MaxValue).ToHexString(), encoded.ToHexString());
        }
示例#7
0
        public void SignedEncodeMax()
        {
            var coder = new HeliumIntegerSigned(0, false, 1);

            coder.Prepare(typeof(Int32));
            var encoded = coder.Encode(SignedVlq.MaxValue);

            Assert.Equal(SignedVlq.Encode(SignedVlq.MaxValue).ToHexString(), encoded.ToHexString());
        }
示例#8
0
        public void SignedDecodeNullableNull()
        {
            var coder = new HeliumIntegerSigned(0, true);

            coder.Prepare(typeof(Int32));
            var decoded = coder.Decode(new DecodeBuffer(SignedVlq.Encode(0).ToArray()));

            Assert.Equal((Int32?)null, decoded);
        }
示例#9
0
        public void SignedDecodeNullableMin()
        {
            var coder = new HeliumIntegerSigned(0, true, 1);

            coder.Prepare(typeof(UInt64));
            var decoded = coder.Decode(new DecodeBuffer(SignedVlq.Encode(SignedVlq.MinValue).ToArray()));

            Assert.Equal(UnsignedVlq.MinValue + 1, decoded);
        }
示例#10
0
        public void SignedDecodeMax()
        {
            var coder = new HeliumIntegerSigned(0, false, 1);

            coder.Prepare(typeof(UInt64));
            var decoded = coder.Decode(new DecodeBuffer(SignedVlq.Encode(SignedVlq.MaxValue).ToArray()));

            Assert.Equal(UnsignedVlq.MaxValue, decoded);
        }
示例#11
0
        public void SignedDecodeZero()
        {
            var coder = new HeliumIntegerSigned(0, false);

            coder.Prepare(typeof(Int32));
            var decoded = coder.Decode(new DecodeBuffer(SignedVlq.Encode(0).ToArray()));

            Assert.Equal((Int32)0, decoded);
        }
示例#12
0
        public void SignedDecodeIncrement()
        {
            var coder = new HeliumIntegerSigned(0, false, 10);

            coder.Prepare(typeof(Int32));
            var decoded = coder.Decode(new DecodeBuffer(new byte[] {
                0x0B
            }));

            Assert.Equal((Int32)110, decoded);
        }