Exemple #1
0
        public void RegKeyTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly initialized");
            string expected = @"SOFTWARE\JavaSoft";
            string actual;

            Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly initialized");
            target.RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft";
            Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated");
            actual = target.RegKey;
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not properly initialized.");

            target.RegKey = string.Empty;
            actual        = target.RegKey;
            Assert.AreEqual(string.Empty, actual, "The property 'RegKey' cannot be set to string.Empty.");

            target.RegKey = @"    HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft    ";
            actual        = target.RegKey;
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not not properly trimed.");

            target.RegKey = @"HKEY_Current_User\SOFTWARE\JavaSoft    ";
            actual        = target.RegKey;
            Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'RefersToCurrentUser' is not properly initialized");
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not not properly updated.");
        }
Exemple #2
0
        public void GetXMLActionTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            target.RegKey   = @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft";
            target.RegValue = "DisplayVersion";
            target.NewData  = "15.0.0.236";
            string expected = "<Action>\r\n<ElementType>CustomActions.ChangeRegDataAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<RegValue>DisplayVersion</RegValue>\r\n<DefaultValue>False</DefaultValue>\r\n<NewData>15.0.0.236</NewData>\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.ChangeRegDataAction</ElementType>\r\n<Hive>HKEY_CURRENT_USER</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<RegValue>DisplayVersion</RegValue>\r\n<DefaultValue>False</DefaultValue>\r\n<NewData>15.0.0.236</NewData>\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.ChangeRegDataAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>SOFTWARE\\JavaSoft</RegKey>\r\n<RegValue>DisplayVersion</RegValue>\r\n<DefaultValue>False</DefaultValue>\r\n<NewData>15.0.0.236</NewData>\r\n<UseReg32>False</UseReg32></Action>";
            actual        = target.GetXMLAction();
            Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string");
        }
Exemple #3
0
        public void HiveNotificationTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            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");
        }
Exemple #4
0
        public void RegValueTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly initialized");
            string expected = "DisplayVersion";
            string actual;

            target.RegValue = expected;
            actual          = target.RegValue;
            Assert.AreEqual(expected, actual, "The property 'RegValue' is not properly updated");
        }
Exemple #5
0
        public void ChangeRegDataActionConstructorTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            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(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive, "The property 'Hive' is not properly initialized");
            Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly initialized");
            Assert.AreEqual(String.Empty, target.RegValue, "The property 'RegValue' is not properly initialized");
            Assert.AreEqual(String.Empty, target.NewData, "The property 'NewData' is not properly initialized");
        }
Exemple #6
0
        public void HiveTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            RegistryHelper.RegistryHive expected = RegistryHelper.RegistryHive.HKey_Local_Machine;
            RegistryHelper.RegistryHive actual;
            target.Hive = expected;
            actual      = target.Hive;
            Assert.AreEqual(expected, actual, "The property 'Hive' is not properly initialized");
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly initialized");

            target.Hive = RegistryHelper.RegistryHive.HKey_Current_User;
            Assert.IsTrue(target.Hive == RegistryHelper.RegistryHive.HKey_Current_User, "The property 'Hive' is not properly updated");
            Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not properly updated");

            target.Hive = RegistryHelper.RegistryHive.HKey_Local_Machine;
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'RefersToHKeyCurrentUser' is not revert-back to false");

            target.RegKey = @"Hkey_Current_user\software\java";
            Assert.IsTrue(target.RefersToHKeyCurrentUser, "The property 'ReferToHKeyCurrentUser' is not properly updated");

            target.RegKey = @"Hkey_Local_Machine\software\java";
            Assert.IsTrue(!target.RefersToHKeyCurrentUser, "The property 'ReferToHKeyCurrentUser' is not properly updated");
        }
Exemple #7
0
        public void ValidateDataTest()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive, "The property 'Hive' is not properly initialized");
            Assert.IsTrue(String.IsNullOrEmpty(target.RegKey), "The propert 'RegKey' is not properly initialized");
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly initialized");
            target.RegKey   = @"SOFTWARE\JavaSoft";
            target.RegValue = "DisplayVersion";
            target.NewData  = "15.0.0.236";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");
            target.RegKey = string.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' doesn't revert back to Misconfigured");
            target.RegKey = @"SOFTWARE\JavaSoft";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");
            target.RegValue = String.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' doesn't revert back to Misconfigured");
            target.RegValue = "DisplayVersion";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");
            target.NewData = String.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' doesn't revert back to Misconfigured");
            target.NewData = "15.0.0.236";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        public void NewDataToNullText()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            target.NewData = null;
        }
Exemple #10
0
        public void RegValueToNullText()
        {
            ChangeRegDataAction target = new ChangeRegDataAction();

            target.RegValue = null;
        }