public void RegKeyTest() { DeleteRegValueAction target = new DeleteRegValueAction(); string expected = @"Software\Microsoft\Windows\CurrentVersion\Policies"; string actual; target.RegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies";; actual = target.RegKey; Assert.AreEqual(expected, actual); Assert.IsTrue(target.RefersToHKeyCurrentUser); expected = @"Software\Microsoft\Windows\CurrentVersion\Policies"; target.RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";; actual = target.RegKey; Assert.AreEqual(expected, actual, true); Assert.IsFalse(target.RefersToHKeyCurrentUser); expected = @"Software\Microsoft\Windows\CurrentVersion\Policies"; target.RegKey = @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";; actual = target.RegKey; Assert.AreEqual(expected, actual, true); Assert.IsFalse(target.RefersToHKeyCurrentUser); expected = @"Software\Microsoft\Windows\CurrentVersion\Policies"; target.RegKey = @"\\\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";; actual = target.RegKey; Assert.AreEqual(expected, actual, true); Assert.IsFalse(target.RefersToHKeyCurrentUser); expected = @"Software\Microsoft\Windows\CurrentVersion\Policies"; target.RegKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";; actual = target.RegKey; Assert.AreEqual(expected, actual, true); Assert.IsFalse(target.RefersToHKeyCurrentUser); }
public void ValueNameTest() { DeleteRegValueAction target = new DeleteRegValueAction(); string expected = "DisplayVersion"; string actual; target.ValueName = " DisplayVersion "; actual = target.ValueName; Assert.AreEqual(expected, actual, true); }
public void DeleteRegValueActionConstructorTest() { DeleteRegValueAction target = new DeleteRegValueAction(); Assert.AreEqual(55, target.Height, "The property 'Height' is not properly initialized"); Assert.IsTrue(target.IsTemplate, "The property 'IsTemplate' is not properly initialized"); Assert.IsFalse(target.IsSelected, "The property 'IsSelected' is not properly initialized"); Assert.AreEqual(string.Empty, target.RegKey, "The property 'RegKey' is not properly initialized"); Assert.AreEqual(String.Empty, target.ValueName, "The property 'ValueName' is not properly initialized"); Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive); Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'referToHKeyCurrentUser' is not properly initialized"); }
public void HiveNotificationTest() { DeleteRegValueAction target = new DeleteRegValueAction(); Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly initialized"); target.Hive = RegistryHelper.RegistryHive.HKey_Current_User; Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated"); target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine; Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated"); target.Hive = RegistryHelper.RegistryHive.Undefined; Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated"); }
public void GetXMLActionTest() { DeleteRegValueAction target = new DeleteRegValueAction(); target.RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft"; target.ValueName = "ValueToDelete"; string expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; string actual; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @" HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft "; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @"HKEY_Current_User\SOFTWARE\JavaSoft"; expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_Current_User</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @"\SOFTWARE\JavaSoft"; target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine; expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @"SOFTWARE\JavaSoft"; target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine; expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @"\SOFTWARE\JavaSoft"; target.Hive = RegistryHelper.RegistryHive.HKey_Current_User; expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_Current_User</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); target.RegKey = @"SOFTWARE\JavaSoft"; target.Hive = RegistryHelper.RegistryHive.HKey_Current_User; expected = "<Action>\r\n<ElementType>CustomActions.DeleteRegValueAction</ElementType>\r\n<Hive>HKEY_Current_User</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<ValueName>ValueToDelete</ValueName>\r\n<UseReg32>False</UseReg32></Action>"; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string"); }
public void HiveTest() { DeleteRegValueAction target = new DeleteRegValueAction(); Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive, "The property 'Hive' is not properly initialized"); target.Hive = RegistryHelper.RegistryHive.HKey_Current_User; Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Current_User, target.Hive, "The property 'Hive' is not properly updated"); Assert.IsTrue(target.RefersToHKeyCurrentUser); target.RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies"; Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive); Assert.IsFalse(target.RefersToHKeyCurrentUser); target.RegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies"; Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Current_User, target.Hive); Assert.IsTrue(target.RefersToHKeyCurrentUser); }
public void ValidateDataTest() { DeleteRegValueAction target = new DeleteRegValueAction(); target.ValidateData(); Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.RegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion"; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.ValueName = "DisplayVersion"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.ValueName = String.Empty; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.ValueName = "DisplayVersion"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.Hive = RegistryHelper.RegistryHive.Undefined; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.RegKey = String.Empty; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); }
private GenericAction GetElementFromXML(XmlReader reader) { GenericAction element = null; string elementType = reader.ReadElementContentAsString(); switch (elementType) { case "CustomActions.AddRegKeyAction": element = new AddRegKeyAction(); break; case "CustomActions.AddRegValueAction": element = new AddRegValueAction(); break; case "CustomActions.ChangeRegDataAction": element = new ChangeRegDataAction(); break; case "CustomActions.ChangeServiceAction": element = new ChangeServiceAction(); break; case "CustomActions.CopyFileAction": element = new CopyFileAction(); break; case "CustomActions.CreateFolderAction": element = new CreateFolderAction(); break; case "CustomActions.CreateShortcutAction": element = new CreateShortcutAction(); break; case "CustomActions.CreateTextFileAction": element = new CreateTextFileAction(); break; case "CustomActions.DeleteFileAction": element = new DeleteFileAction(); break; case "CustomActions.DeleteFolderAction": element = new DeleteFolderAction(); break; case "CustomActions.DeleteRegKeyAction": element = new DeleteRegKeyAction(); break; case "CustomActions.DeleteRegValueAction": element = new DeleteRegValueAction(); break; case "CustomActions.DeleteTaskAction": element = new DeleteTaskAction(); break; case "CustomActions.ExecutableAction": element = new ExecutableAction(); break; case "CustomActions.ImportRegFileAction": element = new ImportRegFileAction(); break; case "CustomActions.KillProcessAction": element = new KillProcessAction(); break; case "CustomActions.RebootAction": element = new RebootAction(); break; case "CustomActions.RegisterDLLAction": element = new RegisterDLLAction(); break; case "CustomActions.RenameFileAction": element = new RenameFileAction(); break; case "CustomActions.RenameFolderAction": element = new RenameFolderAction(); break; case "CustomActions.RenameRegKeyAction": element = new RenameRegKeyAction(); break; case "CustomActions.RenameRegValueAction": element = new RenameRegValueAction(); break; case "CustomActions.RunPowershellScriptAction": element = new RunPowershellScriptAction(); break; case "CustomActions.RunVbScriptAction": element = new RunVbScriptAction(); break; case "CustomActions.ShutdownAction": element = new ShutdownAction(); break; case "CustomActions.StartServiceAction": element = new StartServiceAction(); break; case "CustomActions.StopServiceAction": element = new StopServiceAction(); break; case "CustomActions.UninstallMsiProductByGuidAction": element = new UninstallMsiProductByGuidAction(); break; case "CustomActions.UninstallMsiProductByNameAction": element = new UninstallMsiProductByNameAction(); break; case "CustomActions.UnregisterDLLAction": element = new UnregisterDLLAction(); break; case "CustomActions.UnregisterServiceAction": element = new UnregisterServiceAction(); break; case "CustomActions.WaitAction": element = new WaitAction(); break; case "CustomActions.InstallMsiAction": element = new InstallMsiAction(); break; case "CustomActions.ReturnCode": try { this.SetReturnCodeFromXml(reader); } catch (Exception ex) { if (this.IsUIEnable) { System.Windows.Forms.MessageBox.Show(Localizator.Getinstance().GetLocalizedString("UnableToSetReturnCodeFromXmlFile") + "\r\n" + ex.Message); } else { throw new Exception(Localizator.Getinstance().GetLocalizedString("UnableToSetReturnCodeFromXmlFile") + "\r\n" + ex.Message); } } break; default: if (this.IsUIEnable) { System.Windows.Forms.MessageBox.Show(Localizator.Getinstance().GetLocalizedString("ThisActionHasNotBeenRecognized") + elementType); } else { throw new Exception(Localizator.Getinstance().GetLocalizedString("ThisActionHasNotBeenRecognized") + elementType); } break; } return(element); }