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