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