Example #1
0
        public void ValidateDataTest()
        {
            AddRegValueAction target = new AddRegValueAction();


            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly initialized");
            target.ValidateData();
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly initialized");
            target.RegKey = @"HKLM\Software\Vnc";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.ValueName = "DisplayVersion";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.Type = CustomActions.RegistryHelper.ValueType.REG_SZ;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.Data = "1.2.3.4";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The configuration State is not properly updated");

            target.RegKey = string.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.RegKey = @"HKLM\Software\Vnc";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The configuration State is not properly updated");
            target.ValueName = string.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.ValueName = "DisplayVersion";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The configuration State is not properly updated");
            target.Data = string.Empty;
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The configuration State is not properly updated");
            target.Data = "1.2.3.4";
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The configuration State is not properly updated");
        }
Example #2
0
        public void ValueNameTest()
        {
            AddRegValueAction target   = new AddRegValueAction();
            string            expected = "Displayversion";
            string            actual;

            target.ValueName = expected;
            actual           = target.ValueName;
            Assert.AreEqual(expected, actual, "The property 'ValueName' is not properly initialized");
        }
Example #3
0
        public void TypeTest()
        {
            AddRegValueAction target = new AddRegValueAction();

            CustomActions.RegistryHelper.ValueType expected = CustomActions.RegistryHelper.ValueType.REG_DWORD;
            CustomActions.RegistryHelper.ValueType actual;
            target.Type = expected;
            actual      = target.Type;
            Assert.AreEqual(expected, actual, "The property 'Type' is not properly updated");
        }
Example #4
0
        public void DataTest()
        {
            AddRegValueAction target   = new AddRegValueAction();
            string            expected = "1.2.3.4";
            string            actual;

            target.Data = expected;
            actual      = target.Data;
            Assert.AreEqual(expected, actual, "The property 'Data' is not properly initialized");
        }
Example #5
0
        public void HiveNotificationTest()
        {
            AddRegValueAction target = new AddRegValueAction();

            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");
        }
Example #6
0
        public void AddRegValueActionConstructorTest()
        {
            AddRegValueAction target = new AddRegValueAction();

            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(string.Empty, target.Data, "The property 'Data' is not properly initialized");
            Assert.IsTrue(target.Type == CustomActions.RegistryHelper.ValueType.REG_SZ, "The property 'Type' is not properly initialized");
            Assert.IsFalse(target.RefersToHKeyCurrentUser, "The property 'RefersToCurrentUser' is not properly initialized");
        }
Example #7
0
        public void GetXMLActionTest()
        {
            AddRegValueAction target = new AddRegValueAction();

            target.RegKey    = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            target.ValueName = "DisplayVersion";
            target.Type      = CustomActions.RegistryHelper.ValueType.REG_SZ;
            target.Data      = "1.2.3.4";

            string expected = "<Action>\r\n<ElementType>CustomActions.AddRegValueAction</ElementType>\r\n<Hive>HKEY_LOCAL_MACHINE</Hive>\r\n<RegKey>" + target.RegKey + "</RegKey>\r\n" +
                              "<ValueName>DisplayVersion</ValueName>\r\n" +
                              "<Data>1.2.3.4</Data>\r\n" +
                              "<Type>" + CustomActions.RegistryHelper.ValueType.REG_SZ.ToString() + "</type>\r\n<UseReg32>False</UseReg32></Action>";
            string actual;

            actual = target.GetXMLAction();
            Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' doesn't return the good string");
        }
Example #8
0
        public void RegKeyTest()
        {
            AddRegValueAction target   = new AddRegValueAction();
            string            expected = @"Software\Vnc";
            string            actual;

            target.RegKey = expected;
            actual        = target.RegKey;
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not properly initialized");

            expected      = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            target.RegKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            actual        = target.RegKey;
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not properly initialized");
            Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Local_Machine, target.Hive, "The Hive is not set properly");

            expected      = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            target.RegKey = @"HKEY_Current_User\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies";
            actual        = target.RegKey;
            Assert.AreEqual(expected, actual, "The property 'RegKey' is not properly initialized");
            Assert.AreEqual(RegistryHelper.RegistryHive.HKey_Current_User, target.Hive, "The Hive is not set properly");
        }
Example #9
0
        public void ValueNameToNullText()
        {
            AddRegValueAction target = new AddRegValueAction();

            target.ValueName = null;
        }
Example #10
0
        public void RegKeyToNullText()
        {
            AddRegValueAction target = new AddRegValueAction();

            target.RegKey = null;
        }
Example #11
0
        public void DataToNullText()
        {
            AddRegValueAction target = new AddRegValueAction();

            target.Data = null;
        }
Example #12
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);
        }