Exemplo n.º 1
0
 public void UnsignedPrepareUnsupported()
 {
     Assert.Throws <UnsupportedDataTypeException>(() => {
         var coder = new HeliumIntegerUnsigned(0, false, 10, 20);
         coder.Prepare(typeof(String));
     });
 }
Exemplo n.º 2
0
 public void UnsignedEncodeUnsupported()
 {
     Assert.Throws <FormatException>(() => {
         var coder = new HeliumIntegerUnsigned(0, false, 10, 20);
         coder.Prepare(typeof(UInt32));
         var encoded = coder.Encode("asdf");
     });
 }
Exemplo n.º 3
0
        public void UnsignedEncodeMinimumIncrement2()
        {
            var coder = new HeliumIntegerUnsigned(0, false, 10, 20);

            coder.Prepare(typeof(UInt32));
            var encoded = coder.Encode((UInt32)152);

            Assert.Equal("0D", encoded.ToHexString());
        }
Exemplo n.º 4
0
        public void UnsignedEncodeNullableNull()
        {
            var coder = new HeliumIntegerUnsigned(0, true, 1, 0);

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

            Assert.Equal(UnsignedVlq.Encode(UnsignedVlq.MinValue).ToHexString(), encoded.ToHexString());
        }
Exemplo n.º 5
0
        public void UnsignedEncodeMax()
        {
            var coder = new HeliumIntegerUnsigned(0, false, 1, 0);

            coder.Prepare(typeof(UInt64));
            var encoded = coder.Encode(UnsignedVlq.MaxValue);

            Assert.Equal(UnsignedVlq.Encode(UnsignedVlq.MaxValue).ToHexString(), encoded.ToHexString());
        }
Exemplo n.º 6
0
        public void UnsignedDecodeNullableNull()
        {
            var coder = new HeliumIntegerUnsigned(0, true, 1, 0);

            coder.Prepare(typeof(UInt32?));
            var decoded = coder.Decode(new DecodeBuffer(UnsignedVlq.Encode(0).ToArray()));

            Assert.Equal((UInt32?)null, decoded);
        }
Exemplo n.º 7
0
        public void UnsignedDecodeMax()
        {
            var coder = new HeliumIntegerUnsigned(0, false, 1, 0);

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

            Assert.Equal(UnsignedVlq.MaxValue, decoded);
        }
Exemplo n.º 8
0
        public void UnsignedDecodeMin()
        {
            var coder = new HeliumIntegerUnsigned(0, false, 1, 0);

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

            Assert.Equal((UInt32)0, decoded);
        }
Exemplo n.º 9
0
        public void UnsignedDecodeMinimumIncrement2()
        {
            var coder = new HeliumIntegerUnsigned(0, false, 10, 20);

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

            Assert.Equal((UInt32)150, decoded);
        }