/// <summary>
        /// Change the property <see cref="RefersToHKeyCurrentUser"/> accordingly to the <see cref="Hive"/> property.
        /// </summary>
        public void UpdateHiveNotificationStatus(RegistryHelper.RegistryHive hive)
        {
            switch (hive)
            {
            case RegistryHelper.RegistryHive.HKey_Local_Machine:
                this.RefersToHKeyCurrentUser = false;
                break;

            case RegistryHelper.RegistryHive.HKey_Current_User:
                this.RefersToHKeyCurrentUser = true;
                break;

            default:
                this.RefersToHKeyCurrentUser = false;
                break;
            }
            this.Invalidate();
        }
예제 #2
0
        public void RemoveRegistryHiveReferenceTest()
        {
            string dirtyRegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies";

            RegistryHelper.RegistryHive currentHive = RegistryHelper.RegistryHive.Undefined;
            RegistryHelper.RegKey       expected    = new RegistryHelper.RegKey();
            expected.RegHive    = RegistryHelper.RegistryHive.HKey_Current_User;
            expected.RegKeyName = @"\Software\Microsoft\Windows\CurrentVersion\Policies";
            RegistryHelper.RegKey actual;
            actual = RegistryHelper.RemoveRegistryHiveReference(dirtyRegKey, currentHive);
            Assert.AreEqual(expected.RegKeyName, actual.RegKeyName, true);
            Assert.AreEqual(expected.RegHive, actual.RegHive);

            dirtyRegKey         = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            currentHive         = RegistryHelper.RegistryHive.Undefined;
            expected.RegHive    = RegistryHelper.RegistryHive.HKey_Local_Machine;
            expected.RegKeyName = @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            actual = RegistryHelper.RemoveRegistryHiveReference(dirtyRegKey, currentHive);
            Assert.AreEqual(expected.RegKeyName, actual.RegKeyName, true);
            Assert.AreEqual(expected.RegHive, actual.RegHive);

            dirtyRegKey         = @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            currentHive         = RegistryHelper.RegistryHive.HKey_Local_Machine;
            expected.RegHive    = RegistryHelper.RegistryHive.HKey_Local_Machine;
            expected.RegKeyName = @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            actual = RegistryHelper.RemoveRegistryHiveReference(dirtyRegKey, currentHive);
            Assert.AreEqual(expected.RegKeyName, actual.RegKeyName, true);
            Assert.AreEqual(expected.RegHive, actual.RegHive);

            dirtyRegKey         = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            currentHive         = RegistryHelper.RegistryHive.HKey_Current_User;
            expected.RegHive    = RegistryHelper.RegistryHive.HKey_Current_User;
            expected.RegKeyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            actual = RegistryHelper.RemoveRegistryHiveReference(dirtyRegKey, currentHive);
            Assert.AreEqual(expected.RegKeyName, actual.RegKeyName, true);
            Assert.AreEqual(expected.RegHive, actual.RegHive);
        }
예제 #3
0
        public void HiveTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            RegistryHelper.RegistryHive expected = RegistryHelper.RegistryHive.HKey_Local_Machine;
            RegistryHelper.RegistryHive actual;
            target.Hive = expected;
            actual      = target.Hive;
            Assert.AreEqual(expected, actual, "The property 'Hive' is not properly initialized");
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly initialized");

            target.Hive = RegistryHelper.RegistryHive.HKey_Current_User;
            Assert.IsTrue(target.Hive == RegistryHelper.RegistryHive.HKey_Current_User, "The property 'Hive' is not properly updated");
            Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated");

            target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine;
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not revert-back to false");

            target.RegKey = @"Hkey_Current_user\software\java";
            Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'ReferToHKeyCurrentUser' is not properly updated");

            target.RegKey = @"Hkey_Local_Machine\software\java";
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'ReferToHKeyCurrentUser' is not properly updated");
        }