예제 #1
0
        public void DeserializeTheSameAsSqlServer(int plaintext)
        {
            Database.Insert(new SqlParameter("@parameter", SqlDbType.Int)
            {
                Value = plaintext
            });
            byte[]           ciphertextBytes = Database.SelectCiphertext(SqlDbType.Int);
            byte[]           plaintextBytes  = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes);
            SqlIntSerializer serializer      = new SqlIntSerializer();
            int expectedPlaintext            = serializer.Deserialize(plaintextBytes);
            int actualPlaintext = (int)Database.SelectPlaintext(SqlDbType.Int);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
 /// <summary>
 /// Deserializes the provided <paramref name="bytes"/>
 /// </summary>
 /// <param name="bytes">The data to be deserialized</param>
 /// <returns>The serialized data</returns>
 /// <exception cref="MicrosoftDataEncryptionException">
 /// The length of <paramref name="bytes"/> is less than 8.
 /// </exception>
 public override int?Deserialize(byte[] bytes)
 {
     return(bytes.IsNull() ? (int?)null : serializer.Deserialize(bytes));
 }
예제 #3
0
        public void ShouldThrowIfDeserializingLessThanEightBytes(byte[] data)
        {
            SqlIntSerializer serializer = new SqlIntSerializer();

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data));
        }
예제 #4
0
        public void ShouldThrowIfDeserializingNull()
        {
            SqlIntSerializer serializer = new SqlIntSerializer();

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