Exemple #1
0
        public void CreateFolderActionConstructorTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            Assert.IsTrue(target.IsTemplate, "The Property 'IsTemplate' is not properly initialized");
            Assert.IsFalse(target.IsSelected, "The Property 'IsSelected' is not properly initialized");
            Assert.AreEqual(55, target.Height, "The property 'Height' is not properly initialized.");
            Assert.AreEqual(string.Empty, target.FullPath, "The property 'FullPath' is not properly initialized.");
            Assert.IsFalse(target.RefersToUserProfile);
        }
Exemple #2
0
        public void GetXMLActionTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            target.FullPath = @"C:\Windows\System32\NewFolder";

            string expected = "<Action>\r\n<ElementType>CustomActions.CreateFolderAction</ElementType>\r\n<FullPath>" + target.FullPath + "</FullPath>\r\n</Action>";
            string actual;

            actual = target.GetXMLAction();
            Assert.AreEqual(expected, actual, "The method 'GetXMLAction' doesn't return the good string.");
        }
Exemple #3
0
        public void ValidateDataTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The property 'ConfigurationState' is not properly initialized");
            target.ValidateData();
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated");
            target.FullPath = @"C:\Windows\System32\FolderName";
            target.ValidateData();
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");

            target.FullPath = "";
            target.ValidateData();
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated");
        }
Exemple #4
0
        public void UserProfileNotificationTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            Assert.IsFalse(target.RefersToUserProfile, "The property 'RefersToUserProfile' is not properly initialized");

            foreach (string folder in CommonData.userProfileRelatedFolders)
            {
                target.FullPath = folder;
                Assert.IsTrue(target.RefersToUserProfile, folder + " should set 'RefersToUserProfile' to true.");
            }

            target.FullPath = @"C:\Temp";
            Assert.IsFalse(target.RefersToUserProfile);

            foreach (string folder in CommonData.otherFolders)
            {
                target.FullPath = folder;
                Assert.IsFalse(target.RefersToUserProfile, folder + " should not set 'RefersToUserProfile' to true.");
            }
        }
Exemple #5
0
        public void FullPathTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The property 'ConfigurationState' is not properly initialized");
            string expected = @"C:\Windows\System32\FolderName";
            string actual;

            target.FullPath = expected;
            actual          = target.FullPath;
            Assert.AreEqual(expected, actual, "The property 'FullPath' is not properly initialized.");
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated");

            target.FullPath = string.Empty;
            actual          = target.FullPath;
            Assert.AreEqual(string.Empty, actual, "The property 'FullPath' cannot be set to string.Empty.");
            Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated");

            Assert.IsFalse(target.RefersToUserProfile);
            target.FullPath = @"%AppData%\Borland";
            Assert.IsTrue(target.RefersToUserProfile);
        }
        private void Execute(Folder folder, IWin32Window ownerWindow)
        {
            IXenConnection connection;
            String         name;

            // Different dialogs depending whether we're at the top level or adding a subfolder.
            // Also offer them a choice of connections if the connection they're on is Read Only
            // (although we will also sudo a Read Only command when the FolderAction is run).
            if (folder == null || folder.IsRootFolder || folder.Connection == null || CrossConnectionCommand.IsReadOnly(folder.Connection))
            {
                using (var dialog = new NameAndConnectionPrompt
                {
                    Text = Messages.NEW_FOLDER_DIALOG_TITLE,
                    OKText = Messages.CREATE_MNEMONIC_R,
                    HelpID = "NewFolderDialog"
                })
                {
                    if (dialog.ShowDialog(ownerWindow) != DialogResult.OK)
                    {
                        return;
                    }
                    name       = dialog.PromptedName;
                    connection = dialog.Connection;
                }
            }
            else
            {
                using (var dialog = new InputPromptDialog {
                    Text = Messages.NEW_FOLDER_DIALOG_TITLE,
                    PromptText = Messages.NEW_FOLDER_NAME,
                    OkButtonText = Messages.NEW_FOLDER_BUTTON,
                    HelpID = "NewFolderDialog"
                })
                {
                    if (dialog.ShowDialog(ownerWindow) != DialogResult.OK)
                    {
                        return;
                    }
                    name = dialog.InputText;
                }
                connection = folder.Connection;
            }


            List <string> newPaths = new List <string>();

            foreach (string s in name.Split(';'))
            {
                string n = s;
                Folders.FixupRelativePath(ref n);
                if (string.IsNullOrEmpty(n))
                {
                    continue;
                }

                newPaths.Add(Folders.AppendPath(folder == null ? Folders.PATH_SEPARATOR : folder.opaque_ref, n));
            }

            if (newPaths.Count > 0)
            {
                var action = new CreateFolderAction(connection, newPaths.ToArray());

                action.Completed += Action_Completed;
                action.RunAsync();
            }
        }
Exemple #7
0
        private void Execute(Folder folder, IWin32Window ownerWindow)
        {
            IXenConnection connection;
            String         name;

            // Different dialogs depending whether we're at the top level or adding a subfolder.
            // Also offer them a choice of connections if the connection they're on is Read Only
            // (although we will also sudo a Read Only command when the FolderAction is run).
            if (folder == null || folder.IsRootFolder || folder.Connection == null || CrossConnectionCommand.IsReadOnly(folder.Connection))
            {
                NameAndConnectionPrompt dialog = new NameAndConnectionPrompt();
                dialog.Text   = Messages.NEW_FOLDER_DIALOG_TITLE;
                dialog.OKText = Messages.CREATE_MNEMONIC_R;
                dialog.HelpID = "NewFolderDialog";
                if (dialog.ShowDialog(ownerWindow) != DialogResult.OK)
                {
                    return;
                }
                name       = dialog.PromptedName;
                connection = dialog.Connection;
            }
            else
            {
                name       = InputPromptDialog.Prompt(ownerWindow, Messages.NEW_FOLDER_NAME, Messages.NEW_FOLDER_DIALOG_TITLE, "NewFolderDialog");
                connection = folder.Connection;
            }

            if (name == null)
            {
                return;  // Happens if InputPromptDialog was cancelled
            }
            List <string> newPaths = new List <string>();

            foreach (string s in name.Split(';'))
            {
                string n = s;
                Folders.FixupRelativePath(ref n);
                if (string.IsNullOrEmpty(n))
                {
                    continue;
                }

                newPaths.Add(Folders.AppendPath(folder == null ? Folders.PATH_SEPARATOR : folder.opaque_ref, n));
            }

            if (newPaths.Count > 0)
            {
                var action = new CreateFolderAction(connection, newPaths.ToArray());

                Action <ActionBase> completed = null;
                completed = delegate
                {
                    action.Completed -= completed;
                    if (action.Succeeded)
                    {
                        Program.MainWindow.TrySelectNewNode(delegate(object o)
                        {
                            Folder ff = o as Folder;
                            return(ff != null && newPaths[0] == ff.opaque_ref);
                        }, true, true, true);
                    }
                };

                action.Completed += completed;
                action.RunAsync();
            }
        }
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 FullPathToNullTest()
        {
            CreateFolderAction target = new CreateFolderAction();

            target.FullPath = null;
        }