Exemple #1
0
        public void DeserializeTheSameAsSqlServer(DateTime plaintext, byte precision)
        {
            Database.Insert(new SqlParameter("@parameter", SqlDbType.DateTime2)
            {
                Value = plaintext, Precision = precision
            });
            byte[] ciphertextBytes            = Database.SelectCiphertext(SqlDbType.DateTime2);
            byte[] plaintextBytes             = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes);
            SqlDatetime2Serializer serializer = new SqlDatetime2Serializer(precision);
            DateTime expectedPlaintext        = serializer.Deserialize(plaintextBytes);
            DateTime actualPlaintext          = (DateTime)Database.SelectPlaintext(SqlDbType.DateTime2);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
Exemple #2
0
        public void ShouldThrowIfDeserializingLessThanEightBytes(byte[] data)
        {
            SqlDatetime2Serializer serializer = new SqlDatetime2Serializer();

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data));
        }
Exemple #3
0
        public void ShouldThrowIfDeserializingNull()
        {
            SqlDatetime2Serializer serializer = new SqlDatetime2Serializer();

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