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); }
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); }
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()); }
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); }
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); }