コード例 #1
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);
            SqlBigintSerializer serializer = new SqlBigintSerializer();
            long expectedPlaintext         = serializer.Deserialize(plaintextBytes);
            long actualPlaintext           = (long)Database.SelectPlaintext(SqlDbType.BigInt);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
コード例 #2
0
        public void SerializeTheSameAsSqlServer(long plaintext)
        {
            SqlBigintSerializer serializer = new SqlBigintSerializer();

            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);
        }
コード例 #3
0
        public void ShouldThrowIfDeserializingLessThanEightBytes(byte[] data)
        {
            SqlBigintSerializer serializer = new SqlBigintSerializer();

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data));
        }
コード例 #4
0
        public void ShouldThrowIfDeserializingNull()
        {
            SqlBigintSerializer serializer = new SqlBigintSerializer();

            Assert.Throws <ArgumentNullException>(() => serializer.Deserialize(null));
        }