public void ToInt16FromBigEndian() { Assert.AreEqual(0, SqlBitConverter.ToInt16FromBigEndian(new byte[] { 0x0 }, 0, Offset.Zero)); Assert.AreEqual(239, SqlBitConverter.ToInt16FromBigEndian(new byte[] { 0xEF }, 0, Offset.Zero)); Assert.AreEqual(111, SqlBitConverter.ToInt16FromBigEndian(new byte[] { 0xEF }, 0, Offset.MinValue)); Assert.AreEqual(-112, SqlBitConverter.ToInt16FromBigEndian(new byte[] { 0x10 }, 0, Offset.MinValue)); Assert.AreEqual(20239, SqlBitConverter.ToInt16FromBigEndian(new byte[] { 0x4F, 0x0F }, 0, Offset.Zero)); }
public override object GetValue(byte[] value) { if (CompressionContext.CompressionLevel != CompressionLevel.None) { if (value.Length > 2) { throw new ArgumentException("Invalid value length: " + value.Length); } return(SqlBitConverter.ToInt16FromBigEndian(value, 0, Offset.MinValue)); } else { if (value.Length != 2) { throw new ArgumentException("Invalid value length: " + value.Length); } return(BitConverter.ToInt16(value, 0)); } }