Exemple #1
0
            public void DeleteAllSubKey_WhenCalledWithHKLM64()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("DeleteRegKeyActionHKLM64.CustAct"));
                RegistryKey hklm        = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                RegistryKey targetKey   = hklm.OpenSubKey(action.RegKey, true);
                RegistryKey targetKey2  = null;
                var         finalResult = Tools.GetReturnCodeAction();

                // Act
                if (targetKey == null)
                {
                    targetKey2 = hklm.CreateSubKey(action.RegKey);
                    targetKey2.CreateSubKey(@"SubKey\SubKey\SubKey");
                }
                if (targetKey2 == null)
                {
                    targetKey.CreateSubKey(@"SubKey\SubKey\SubKey");
                }
                action.Run(ref finalResult);
                targetKey = hklm.OpenSubKey(action.RegKey, false);

                // Assert
                Assert.IsNull(targetKey);
            }
Exemple #2
0
            public void DoNothing_WhenTryingToDeleteRegKeyThatDoesNotExists()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("DeleteRegKeyActionNotExists.CustAct"));
                RegistryKey hklm        = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                var         finalResult = Tools.GetReturnCodeAction();
                RegistryKey targetKey   = null;

                // Act

                action.Run(ref finalResult);
                targetKey = hklm.OpenSubKey(action.RegKey, false);

                // Assert
                Assert.IsNull(targetKey);
            }
Exemple #3
0
            public void DeleteTheRegKey_WhenCalledWithHKCU()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("DeleteRegKeyActionHKCU.CustAct"));
                RegistryKey hkcu        = Registry.CurrentUser;
                RegistryKey targetKey   = hkcu.OpenSubKey(action.RegKey, false);
                var         finalResult = Tools.GetReturnCodeAction();

                // Act
                if (targetKey == null)
                {
                    hkcu.CreateSubKey(action.RegKey);
                }
                action.Run(ref finalResult);
                targetKey = hkcu.OpenSubKey(action.RegKey, false);

                // Assert
                Assert.IsNull(targetKey);
            }