Пример #1
0
        public void Test_Decode_Byte()
        {
            var  transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            byte value      = 0x0;
            var  bytes      = new[] { value };

            //sbyte and byte are not-supported by 1.X SDK
            Assert.Throws <ArgumentException>(() => transcoder.Decode <byte>(bytes, 0, bytes.Length, OperationCode.Get));
        }
Пример #2
0
        public void Test_Decode_ByteArray()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value      = new byte[] { 0x00, 0x00, 0x01 };
            var bytes      = GetBytes(value);

            var actual = transcoder.Decode <byte[]>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #3
0
        public void Test_Decode_Double()
        {
            var    transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            double value      = 1.2;
            var    bytes      = GetBytes(value);

            var actual = transcoder.Decode <double>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #4
0
        public void Test_Decode_String()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value      = "astring";
            var bytes      = Encoding.UTF8.GetBytes(value);

            var actual = transcoder.Decode <string>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #5
0
        public void Test_Decode_Int()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var five       = 5;
            var bytes      = BitConverter.GetBytes(five);

            var actual = transcoder.Decode <int>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(five, actual);
        }
Пример #6
0
        public void Test_Decode_EmptyByteArray()
        {
            var    transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            object value      = new byte[0];
            var    bytes      = GetBytes(value);

            var actual = transcoder.Decode <object>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #7
0
        public void Test_Decode_UInt16()
        {
            var   transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            Int16 value      = 1;
            var   bytes      = BitConverter.GetBytes(value);

            var actual = transcoder.Decode <Int16>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_Poco()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value = new Person { Name = "jeff" };
            var bytes = GetBytes(value);

            var actual = transcoder.Decode<Person>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value.Name, actual.Name);
        }
        public void Test_Decode_Char()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value = 'o';
            var bytes = Encoding.UTF8.GetBytes(new[] {value});

            var actual = transcoder.Decode<char>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #10
0
        public void Test_Decode_DateTime()
        {
            var      transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            DateTime value      = DateTime.Now;
            var      bytes      = BitConverter.GetBytes(value.Ticks);

            var actual = transcoder.Decode <DateTime>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_String()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value = "astring";
            var bytes = Encoding.UTF8.GetBytes(value);

            var actual = transcoder.Decode<string>(bytes, 0, bytes.Length,OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_EmptyByteArray()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            object value = new byte[0];
            var bytes = GetBytes(value);

            var actual = transcoder.Decode<object>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #13
0
        public void Test_Decode_Char()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value      = 'o';
            var bytes      = Encoding.UTF8.GetBytes(new[] { value });

            var actual = transcoder.Decode <char>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
Пример #14
0
        public void Test_Decode_Boolean()
        {
            var  transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            bool value      = true;
            var  bytes      = BitConverter.GetBytes(value);

            var actual = transcoder.Decode <bool>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_Int()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var five = 5;
            var bytes = BitConverter.GetBytes(five);

            var actual = transcoder.Decode<int>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(five, actual);

        }
Пример #16
0
        public void Test_Decode_Poco()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value      = new Person {
                Name = "jeff"
            };
            var bytes = GetBytes(value);

            var actual = transcoder.Decode <Person>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value.Name, actual.Name);
        }
        public void Test_Decode_Boolean()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            bool value = true;
            var bytes = BitConverter.GetBytes(value);

            var actual = transcoder.Decode<bool>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_DateTime()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            DateTime value = DateTime.Now;
            var bytes = BitConverter.GetBytes(value.Ticks);

            var actual = transcoder.Decode<DateTime>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_ByteArray()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            var value = new byte[] { 0x00, 0x00, 0x01 };
            var bytes = GetBytes(value);

            var actual = transcoder.Decode<byte[]>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_Short()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            short value = 1;
            var bytes = BitConverter.GetBytes(value);

            var actual = transcoder.Decode<short>(bytes, 0, bytes.Length, OperationCode.Get);

            Assert.AreEqual(value, actual);
        }
        public void Test_Decode_Byte()
        {
            var transcoder = new BinaryToJsonTranscoder(new DefaultConverter());
            byte value = 0x0;
            var bytes = new[] {value};

            //sbyte and byte are not-supported by 1.X SDK
            Assert.Throws<ArgumentException>(()=>transcoder.Decode<byte>(bytes, 0, bytes.Length, OperationCode.Get));
        }