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

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

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

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

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

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

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Deserialize(data));
        }
コード例 #5
0
        public void ThrowWhenValueOutOfRange(DateTime?plaintext)
        {
            Serializer <DateTime?> serializer = new SqlNullableDatetimeSerializer();

            Assert.Throws <ArgumentOutOfRangeException>(() => serializer.Serialize(plaintext));
        }