public void CreateTheRegValue_WhenCalledWithHKLM64() { // Arrange SUT action = new SUT(Tools.GetXmlFragment("AddRegValueToHKLM64.CustAct")); RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); RegistryKey targetKey = hklm.OpenSubKey(action.RegKey, true); var finalResult = Tools.GetReturnCodeAction(); object newValue = null; // Act if (targetKey != null) { targetKey.DeleteValue(action.ValueName, false); } action.Run(ref finalResult); if (targetKey == null) { targetKey = hklm.OpenSubKey(action.RegKey, false); } newValue = targetKey.GetValue(action.ValueName, null); // Assert Assert.IsNotNull(newValue); Assert.AreEqual(action.Data, newValue); }
public void CreateRegValue_WhenCalledWithHKCU() { // Arrange SUT action = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU.CustAct")); RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Microsoft.Win32.RegistryView.Registry32); RegistryKey targetKey = hkcu.OpenSubKey(action.RegKey, true); var finalResult = Tools.GetReturnCodeAction(); object newValue = null; // Act targetKey.DeleteValue(action.ValueName, false); action.Run(ref finalResult); newValue = targetKey.GetValue(action.ValueName, null); // Assert Assert.IsNotNull(newValue); Assert.AreEqual(action.Data, newValue); }
public void CreateAReg_SzValue_WhenCalledWithReg_EXPAND_SZ() { // Arrange SUT action = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU_Reg_EXPAND_SZ.CustAct")); RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Microsoft.Win32.RegistryView.Registry32); RegistryKey targetKey = hkcu.OpenSubKey(action.RegKey, true); var finalResult = Tools.GetReturnCodeAction(); object newValue = null; RegistryValueKind kindOfNewValue; // Act targetKey.DeleteValue(action.ValueName, false); action.Run(ref finalResult); newValue = targetKey.GetValue(action.ValueName, null); kindOfNewValue = targetKey.GetValueKind(action.ValueName); // Assert Assert.IsNotNull(newValue); Assert.AreEqual(RegistryValueKind.ExpandString.ToString(), kindOfNewValue.ToString(), true); }