コード例 #1
0
        public void DeserializeTheSameAsSqlServer(DateTime plaintext)
        {
            Database.Insert(new SqlParameter("@parameter", SqlDbType.SmallDateTime)
            {
                Value = plaintext
            });
            byte[] ciphertextBytes = Database.SelectCiphertext(SqlDbType.SmallDateTime);
            byte[] plaintextBytes  = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes);
            SqlSmalldatetimeSerializer serializer = new SqlSmalldatetimeSerializer();
            DateTime expectedPlaintext            = serializer.Deserialize(plaintextBytes);
            DateTime actualPlaintext = (DateTime)Database.SelectPlaintext(SqlDbType.SmallDateTime);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
コード例 #2
0
        public void ShouldThrowIfDeserializingLessThanFourBytes(byte[] data)
        {
            SqlSmalldatetimeSerializer serializer = new SqlSmalldatetimeSerializer();

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

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