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