Exemplo n.º 1
0
        public static void ReadCborNegativeIntegerEncoding_EmptyBuffer_ShouldThrowFormatException()
        {
            byte[] encoding = Array.Empty <byte>();
            var    reader   = new CborReader(encoding);

            Assert.Throws <FormatException>(() => reader.ReadCborNegativeIntegerEncoding());
            Assert.Equal(encoding.Length, reader.BytesRemaining);
        }
Exemplo n.º 2
0
        public static void ReadCborNegativeIntegerEncoding_InvalidData_ShouldThrowFormatException(string hexEncoding)
        {
            byte[] encoding = hexEncoding.HexToByteArray();
            var    reader   = new CborReader(encoding);

            Assert.Throws <FormatException>(() => reader.ReadCborNegativeIntegerEncoding());
            Assert.Equal(encoding.Length, reader.BytesRemaining);
        }
Exemplo n.º 3
0
        public static void ReadCborNegativeIntegerEncoding_SingleValue_HappyPath(ulong expectedResult, string hexEncoding)
        {
            byte[] data         = hexEncoding.HexToByteArray();
            var    reader       = new CborReader(data);
            ulong  actualResult = reader.ReadCborNegativeIntegerEncoding();

            Assert.Equal(expectedResult, actualResult);
            Assert.Equal(CborReaderState.Finished, reader.PeekState());
        }
Exemplo n.º 4
0
        public static void ReadCborNegativeIntegerEncoding_InvalidTypes_ShouldThrowInvalidOperationException(string hexEncoding)
        {
            byte[] encoding = hexEncoding.HexToByteArray();
            var    reader   = new CborReader(encoding);

            Assert.Throws <InvalidOperationException>(() => reader.ReadCborNegativeIntegerEncoding());

            Assert.Equal(0, reader.BytesRead);
        }
Exemplo n.º 5
0
        public static void ReadCborNegativeIntegerEncoding_InvalidTypes_ShouldThrowInvalidOperationException(string hexEncoding)
        {
            byte[] encoding = hexEncoding.HexToByteArray();
            var    reader   = new CborReader(encoding);

            InvalidOperationException exn = Assert.Throws <InvalidOperationException>(() => reader.ReadCborNegativeIntegerEncoding());

            Assert.Equal("Data item major type mismatch.", exn.Message);

            Assert.Equal(encoding.Length, reader.BytesRemaining);
        }