示例#1
0
        public void TestEncryptedParts_Decrypt_Object()
        {
            var cipher   = GetCipher();
            var instance = new object();
            var target1  = new EncryptedParts(instance, cipher);

            target1.Encrypt();

            var target2 = new EncryptedParts(instance, cipher);

            target2.Decrypt();

            // should succeed
            Assert.IsTrue(true);
        }
示例#2
0
        public void TestEncryptedParts_Decrypt_Default_ClassTwoPropertiesOneFieldTwoEncrypted()
        {
            var cipher   = GetCipher();
            var instance = new ClassTwoPropertiesOneFieldTwoEncrypted();
            var target1  = new EncryptedParts(instance, cipher);

            target1.Encrypt();

            Assert.IsTrue(instance.Encrypted != null);
            Assert.IsTrue(instance.Encrypted.Length != 0);

            var target2 = new EncryptedParts(instance, cipher);

            target2.Decrypt();

            Assert.IsNull(instance.Decrypted1);
        }
示例#3
0
        public void TestEncryptedParts_Decrypt_ClassTwoPropertiesTwoEncrypted()
        {
            var cipher   = GetCipher();
            var instance = new ClassTwoPropertiesTwoEncrypted {
                Decrypted1 = "Cooper"
            };
            var target1 = new EncryptedParts(instance, cipher);

            target1.Encrypt();

            Assert.IsTrue(instance.Encrypted != null);
            Assert.IsTrue(instance.Encrypted.Length != 0);

            var target2 = new EncryptedParts(instance, cipher);

            target2.Decrypt();

            Assert.AreEqual("Cooper", instance.Decrypted1);
        }
示例#4
0
        public void TestEncryptedParts_RoundTrip_ClassOnePropertyOneEncrypted()
        {
            var cipher   = GetCipher();
            var instance = new ClassOnePropertyOneEncrypted {
                Decrypted1 = "pipi"
            };
            var target1 = new EncryptedParts(instance, cipher);

            target1.Encrypt();

            Assert.IsTrue(instance.Encrypted != null);
            Assert.IsTrue(instance.Encrypted.Length != 0);

            var target2 = new EncryptedParts(instance, cipher);

            target2.Decrypt();

            Assert.AreEqual("pipi", instance.Decrypted1);
        }
示例#5
0
        public void TestEncryptedParts_Decrypt_ClassTwoPropertiesOneFieldTwoEncrypted()
        {
            var cipher   = GetCipher();
            var instance = new ClassTwoPropertiesOneFieldTwoEncrypted {
                Decrypted1 = "gogo",
            };

            instance.SetDecrypted3(3);
            var target1 = new EncryptedParts(instance, cipher);

            target1.Encrypt();

            Assert.IsTrue(instance.Encrypted != null);
            Assert.IsTrue(instance.Encrypted.Length != 0);

            var target2 = new EncryptedParts(instance, cipher);

            target2.Decrypt();

            Assert.AreEqual("gogo", instance.Decrypted1);
            Assert.AreEqual(3, instance.GetDecrypted3());
        }