Beispiel #1
0
        public void Test_Decode_Object_Fails()
        {
            var transcoder = new RawBinaryTranscoder();

            var flags = new Flags
            {
                DataFormat = DataFormat.String
            };

            var memory = new ReadOnlyMemory <byte>(Encoding.UTF8.GetBytes("Hello, world!"));

            Assert.Throws <InvalidOperationException>(() => transcoder.Decode <object>(memory, flags, OpCode.NoOp));
        }
Beispiel #2
0
        public void Test_Decode_ByteArrays(DataFormat dataFormat)
        {
            var transcoder = new RawBinaryTranscoder();

            var flags = new Flags
            {
                DataFormat = dataFormat //Note flags type is independent of T - everything is byte[]
            };

            var memory = new ReadOnlyMemory <byte>(new byte[] { 0x0, 0x1 });
            var bytes  = transcoder.Decode <byte[]>(memory, flags, OpCode.NoOp);

            Assert.True(bytes.Length == 2);
        }
Beispiel #3
0
        public void Test_Decode_ByteArrays()
        {
            var transcoder = new RawBinaryTranscoder();

            var flags = new Flags
            {
                DataFormat = DataFormat.Binary
            };

            var memory = new ReadOnlyMemory <byte>(new byte[] { 0x0, 0x1 });
            var bytes  = transcoder.Decode <byte[]>(memory, flags, OpCode.NoOp);

            Assert.True(bytes.Length == 2);
        }