public void ProperlyInitializeProperties_WhenCalledWithHKCU() { // Arrange SUT action = new SUT(Tools.GetXmlFragment("ChangeRegDataActionHKCU.CustAct")); // Act // Assert Assert.AreEqual(action.Hive, "HKey_Current_User"); Assert.AreEqual(action.RegKey, @"Software\EasyCompany\Wsus Package Publisher\Test"); Assert.AreEqual(action.RegValue, "ChangeMe"); Assert.AreEqual(action.NewData, "NewValue"); }
public void ModifiedTheValueInHKLM32_WhenTheValueAlreadyExist() { // Arrange SUT action = new SUT(Tools.GetXmlFragment("ChangeRegDataActionHKLM32.CustAct")); RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); RegistryKey targetKey = hklm.OpenSubKey(action.RegKey, true); targetKey.SetValue(action.RegValue, "OldData"); Assert.AreEqual("OldData", targetKey.GetValue(action.RegValue, null)); var finalResult = Tools.GetReturnCodeAction(); // Act action.Run(ref finalResult); string targetValueContent = (string)targetKey.GetValue(action.RegValue, null); // Assert Assert.IsNotNull(targetValueContent); Assert.AreEqual(action.NewData, targetValueContent); }