Ejemplo n.º 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);
            }
Ejemplo n.º 2
0
            public void ProperlyInitializeProperties_WhenCalledWithHKCU()
            {
                // Arrange
                SUT action = new SUT(Tools.GetXmlFragment("DeleteRegKeyActionHKCU.CustAct"));

                // Act

                // Assert
                Assert.AreEqual(action.Hive, "HKey_Current_User");
                Assert.AreEqual(action.RegKey, @"SOFTWARE\EasyCompany\Wsus Package Publisher\Test");
            }
Ejemplo n.º 3
0
            public void ProperlyInitializeProperties_WhenCalledWithHKLM64()
            {
                // Arrange
                SUT action = new SUT(Tools.GetXmlFragment("DeleteRegKeyActionHKLM64.CustAct"));

                // Act

                // Assert
                Assert.AreEqual(action.Hive, "HKey_Local_Machine");
                Assert.AreEqual(action.RegKey, @"SOFTWARE\EasyCompany\Wsus Package Publisher\Test");
                Assert.IsFalse(action.UseReg32);
            }
Ejemplo n.º 4
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);
            }
Ejemplo n.º 5
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);
            }