示例#1
0
            public void DeleteTheRegValue_WhenCalledWithHKLM()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("DeleteRegValueHKLM32.CustAct"));
                RegistryKey hklm        = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry32);
                RegistryKey targetKey   = hklm.OpenSubKey(action.RegKey, true);
                var         finalResult = Tools.GetReturnCodeAction();

                // Act
                if (targetKey == null)
                {
                    targetKey = hklm.CreateSubKey(action.RegKey);
                }
                object valueToDelete = targetKey.GetValue(action.ValueName, null);

                if (valueToDelete == null)
                {
                    targetKey.SetValue(action.ValueName, 12, RegistryValueKind.DWord);
                }
                valueToDelete = targetKey.GetValue(action.ValueName, null);
                Assert.IsNotNull(valueToDelete);
                action.Run(ref finalResult);
                valueToDelete = targetKey.GetValue(action.ValueName, null);

                // Assert
                Assert.IsNull(valueToDelete);
            }
示例#2
0
            public void ProperlyInitializeProperties_WhenCalledWithHKCU()
            {
                // Arrange
                SUT action = new SUT(Tools.GetXmlFragment("DeleteRegValueHKCU.CustAct"));

                // Act

                // Assert
                Assert.AreEqual(action.Hive, "HKey_Current_User");
                Assert.AreEqual(action.RegKey, @"SOFTWARE\EasyCompany\Wsus Package Publisher\Test");
                Assert.AreEqual(action.ValueName, "DeleteMe");
            }
示例#3
0
            public void DoNothing_WhenRegValueDoesNotExists()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("DeleteRegValueHKCUNotExists.CustAct"));
                RegistryKey hkcu        = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Microsoft.Win32.RegistryView.Registry32);
                RegistryKey targetKey   = hkcu.OpenSubKey(action.RegKey, true);
                var         finalResult = Tools.GetReturnCodeAction();

                // Act
                if (targetKey == null)
                {
                    targetKey = hkcu.CreateSubKey(action.RegKey);
                }
                object valueToDelete = targetKey.GetValue(action.ValueName, null);

                Assert.IsNull(valueToDelete);
                action.Run(ref finalResult);
                valueToDelete = targetKey.GetValue(action.ValueName, null);

                // Assert
                Assert.IsNull(valueToDelete);
            }