public void ReturnNullIfDeserializingNull() { SqlCharSerializer serializer = new SqlCharSerializer(); string actualDeserializedValue = serializer.Deserialize(null); Assert.Null(actualDeserializedValue); }
public void ReturnNullIfSerializingNull() { SqlCharSerializer serializer = new SqlCharSerializer(); byte[] actualSerializedValue = serializer.Serialize(null); Assert.Null(actualSerializedValue); }
public void DeserializeTheSameAsSqlServer(string plaintext, int size, int codepage) { Database.Insert(new SqlParameter("@parameter", SqlDbType.Char, size) { Value = plaintext }); byte[] ciphertextBytes = Database.SelectCiphertext(SqlDbType.Char); byte[] plaintextBytes = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes); SqlCharSerializer serializer = new SqlCharSerializer(size, codepage); string expectedPlaintext = serializer.Deserialize(plaintextBytes); string actualPlaintext = (string)Database.SelectPlaintext(SqlDbType.Char); Assert.Equal(expectedPlaintext, actualPlaintext); }
public void SerializeTheSameAsSqlServer(string plaintext, int size, int codepage) { SqlCharSerializer serializer = new SqlCharSerializer(size, codepage); byte[] serializedPlaintext = serializer.Serialize(plaintext); byte[] actualCiphertext = deterministicEncryptionAlgorithm.Encrypt(serializedPlaintext); Database.Insert(new SqlParameter("@parameter", SqlDbType.Char, size) { Value = plaintext }); byte[] expectedCiphertext = Database.SelectCiphertext(SqlDbType.Char); Assert.Equal(expectedCiphertext, actualCiphertext); }
public void ThrowWhenPropertySizeOutOfRange(int size) { SqlCharSerializer serializer = new SqlCharSerializer(); Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Size = size); }