コード例 #1
0
        public void WhenSecureStringIsNull_RemainsNull()
        {
            this.hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var registryKey = hkcu.CreateSubKey(TestKeyPath);

            var original = new KeyWithSecureString()
            {
            };

            new RegistryBinder <KeyWithSecureString>().Store(original, registryKey);

            var copy = new RegistryBinder <KeyWithSecureString>().Load(registryKey);

            Assert.IsNull(copy.Secure);
        }
コード例 #2
0
        public void WhenSecureStringIsNull_RemainsNull()
        {
            this.hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var registryKey = hkcu.CreateSubKey(TestKeyPath);

            var original = new KeyWithSecureString()
            {
            };

            new RegistryKeyMapper <KeyWithSecureString>().MapObjectToKey(original, registryKey);

            var copy = new RegistryKeyMapper <KeyWithSecureString>().MapKeyToObject(registryKey);

            Assert.IsNull(copy.Secure);
        }
コード例 #3
0
        public void WhenSecureStringStored_StringCanBeDecrypted()
        {
            this.hkcu.DeleteSubKeyTree(TestKeyPath, false);
            var registryKey = hkcu.CreateSubKey(TestKeyPath);

            var original = new KeyWithSecureString()
            {
                Secure = SecureStringExtensions.FromClearText("secure!!!")
            };

            new RegistryBinder <KeyWithSecureString>().Store(original, registryKey);

            var copy = new RegistryBinder <KeyWithSecureString>().Load(registryKey);

            Assert.AreEqual(
                "secure!!!",
                copy.Secure.AsClearText());
        }