Ejemplo n.º 1
0
        public void ReturnNullIfDeserializingNull()
        {
            Serializer <string> serializer = new SqlNcharSerializer();
            string actualDeserializedValue = serializer.Deserialize(null);

            Assert.Null(actualDeserializedValue);
        }
Ejemplo n.º 2
0
        public void ReturnNullIfSerializingNull()
        {
            Serializer <string> serializer = new SqlNcharSerializer();

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

            Assert.Null(actualSerializedValue);
        }
Ejemplo n.º 3
0
        public void DeserializeTheSameAsSqlServer(string plaintext, int size)
        {
            Database.Insert(new SqlParameter("@parameter", SqlDbType.NChar, size)
            {
                Value = plaintext
            });
            byte[] ciphertextBytes         = Database.SelectCiphertext(SqlDbType.NChar);
            byte[] plaintextBytes          = deterministicEncryptionAlgorithm.Decrypt(ciphertextBytes);
            Serializer <string> serializer = new SqlNcharSerializer(size);
            string expectedPlaintext       = serializer.Deserialize(plaintextBytes);
            string actualPlaintext         = (string)Database.SelectPlaintext(SqlDbType.NChar);

            Assert.Equal(expectedPlaintext, actualPlaintext);
        }
Ejemplo n.º 4
0
        public void SerializeTheSameAsSqlServer(string plaintext, int size)
        {
            Serializer <string> serializer = new SqlNcharSerializer(size);

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

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

            Assert.Equal(expectedCiphertext, actualCiphertext);
        }