コード例 #1
0
        public void ReturnNullIfSerializingNull()
        {
            Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer();

            byte[] actualSerializedValue = serializer.Serialize(null);

            Assert.Null(actualSerializedValue);
        }
コード例 #2
0
        public void SerializeTheSameAsSqlServer(DateTime?plaintext)
        {
            Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer();

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

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

            Assert.Equal(expectedCiphertext, actualCiphertext);
        }
コード例 #3
0
        public void ThrowWhenValueOutOfRange(DateTime?plaintext)
        {
            Serializer <DateTime?> serializer = new SqlNullableSmalldatetimeSerializer();

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