public void DeserializeTheSameAsSqlServer(short plaintext) { Database.Insert(new SqlParameter("@parameter", SqlDbType.SmallInt) { Value = plaintext }); byte[] ciphertextBytes = Database.SelectCiphertext(SqlDbType.SmallInt); byte[] plaintextBytes = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes); SqlSmallintSerializer serializer = new SqlSmallintSerializer(); short expectedPlaintext = serializer.Deserialize(plaintextBytes); short actualPlaintext = (short)Database.SelectPlaintext(SqlDbType.SmallInt); Assert.Equal(expectedPlaintext, actualPlaintext); }
public void SerializeTheSameAsSqlServer(short plaintext) { SqlSmallintSerializer serializer = new SqlSmallintSerializer(); byte[] serializedPlaintext = serializer.Serialize(plaintext); byte[] expectedCiphertext = deterministicEncryptionAlgorithm.Encrypt(serializedPlaintext); Database.Insert(new SqlParameter("@parameter", SqlDbType.SmallInt) { Value = plaintext }); byte[] actualCiphertext = Database.SelectCiphertext(SqlDbType.SmallInt); Assert.Equal(expectedCiphertext, actualCiphertext); }
public void ShouldThrowIfDeserializingLessThanEightBytes(byte[] data) { SqlSmallintSerializer serializer = new SqlSmallintSerializer(); Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data)); }
public void ShouldThrowIfDeserializingNull() { SqlSmallintSerializer serializer = new SqlSmallintSerializer(); Assert.Throws <ArgumentNullException>(() => serializer.Deserialize(null)); }