public void DeserializeTheSameAsSqlServer(DateTime plaintext) { Database.Insert(new SqlParameter("@parameter", SqlDbType.SmallDateTime) { Value = plaintext }); byte[] ciphertextBytes = Database.SelectCiphertext(SqlDbType.SmallDateTime); byte[] plaintextBytes = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes); SqlSmalldatetimeSerializer serializer = new SqlSmalldatetimeSerializer(); DateTime expectedPlaintext = serializer.Deserialize(plaintextBytes); DateTime actualPlaintext = (DateTime)Database.SelectPlaintext(SqlDbType.SmallDateTime); Assert.Equal(expectedPlaintext, actualPlaintext); }
public void ShouldThrowIfDeserializingLessThanFourBytes(byte[] data) { SqlSmalldatetimeSerializer serializer = new SqlSmalldatetimeSerializer(); Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data)); }
public void ShouldThrowIfDeserializingNull() { SqlSmalldatetimeSerializer serializer = new SqlSmalldatetimeSerializer(); Assert.Throws <ArgumentNullException>(() => serializer.Deserialize(null)); }