コード例 #1
0
        public void ReturnNullIfDeserializingNull()
        {
            Serializer <long?> serializer = new SqlNullableBigintSerializer();
            long?actualDeserializedValue  = serializer.Deserialize(null);

            Assert.Null(actualDeserializedValue);
        }
コード例 #2
0
        public void DeserializeTheSameAsSqlServer(long?plaintext)
        {
            Database.Insert(new SqlParameter("@parameter", SqlDbType.BigInt)
            {
                Value = plaintext
            });
            byte[]             ciphertextBytes = Database.SelectCiphertext(SqlDbType.BigInt);
            byte[]             plaintextBytes  = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes);
            Serializer <long?> serializer      = new SqlNullableBigintSerializer();
            long?expectedPlaintext             = serializer.Deserialize(plaintextBytes);
            long?actualPlaintext = (long?)Database.SelectPlaintext(SqlDbType.BigInt);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
コード例 #3
0
        public void SerializeTheSameAsSqlServer(long?plaintext)
        {
            Serializer <long?> serializer = new SqlNullableBigintSerializer();

            byte[] serializedPlaintext = serializer.Serialize(plaintext);
            byte[] expectedCiphertext  = deterministicEncryptionAlgorithm.Encrypt(serializedPlaintext);

            Database.Insert(new SqlParameter("@parameter", SqlDbType.BigInt)
            {
                Value = plaintext
            });
            byte[] actualCiphertext = Database.SelectCiphertext(SqlDbType.BigInt);

            Assert.Equal(expectedCiphertext, actualCiphertext);
        }
コード例 #4
0
        public void ShouldThrowIfDeserializingLessThanEightBytes(byte[] data)
        {
            Serializer <long?> serializer = new SqlNullableBigintSerializer();

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data));
        }