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