public void ReturnNullIfSerializingNull() { Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer(); byte[] actualSerializedValue = serializer.Serialize(null); Assert.Null(actualSerializedValue); }
public void SerializeTheSameAsSqlServer(DateTime?plaintext) { Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer(); byte[] serializedPlaintext = serializer.Serialize(plaintext); byte[] expectedCiphertext = deterministicEncryptionAlgorithm.Encrypt(serializedPlaintext); Database.Insert(new SqlParameter("@parameter", SqlDbType.SmallDateTime) { Value = plaintext }); byte[] actualCiphertext = Database.SelectCiphertext(SqlDbType.SmallDateTime); Assert.Equal(expectedCiphertext, actualCiphertext); }
public void ThrowWhenValueOutOfRange(DateTime?plaintext) { Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer(); Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Serialize(plaintext)); }