public void FolderPathTest() { RenameFolderAction target = new RenameFolderAction(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The property 'ConfigurationState' is not properly initialized"); string expected = @"C:\Windows\System32\OldConfig"; string actual; target.FolderPath = expected; actual = target.FolderPath; Assert.AreEqual(expected, actual, "The property 'FolderPath' is not properly initialized."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated"); target.NewName = "Config"; Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated"); target.FolderPath = string.Empty; actual = target.FolderPath; Assert.AreEqual(string.Empty, actual, "The property 'FolderPath' cannot be set to string.Empty."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated"); target.FolderPath = @" C:\Windows\System32\OldConfig "; actual = target.FolderPath; Assert.AreEqual(expected, actual, "The property 'FolderPath' is not not properly trimed."); }
public void ValidateDataTest() { RenameFolderAction target = new RenameFolderAction(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "'ConfigurationState' is not properly initialized."); target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "'ConfigurationState' is not properly updated."); target.FolderPath = @"C:\Windows\System32\OldFolder"; target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "'ConfigurationState' is not properly updated."); target.NewName = "NewName"; target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "'ConfigurationState' is not properly updated."); target.FolderPath = string.Empty; target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "'ConfigurationState' is not properly updated."); target.FolderPath = @"C:\Windows\System32\OldFolder"; target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "'ConfigurationState' is not properly updated."); target.NewName = string.Empty; target.ValidateData(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "'ConfigurationState' is not properly updated."); }
public void NewNameToNullTest() { RenameFolderAction target = new RenameFolderAction(); Assert.AreEqual <string>(string.Empty, target.NewName, "The property 'NewName' is not properly initialized."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The 'ConfigurationState' is not properly initialized."); target.NewName = null; }
public void GetXMLActionTest() { RenameFolderAction target = new RenameFolderAction(); string expected = "<Action>\r\n<ElementType>CustomActions.RenameFolderAction</ElementType>\r\n<FolderPath>" + target.FolderPath + "</FolderPath>\r\n<NewName>" + target.NewName + "</NewName>\r\n</Action>"; string actual; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, "The 'GetXMLAction' method doesn't return the good string."); }
public void RenameFolderActionConstructorTest() { RenameFolderAction target = new RenameFolderAction(); Assert.AreEqual(55, target.Height, "The property 'Height' is not properly initialized."); Assert.IsTrue(target.IsTemplate, "The 'Template' property is not properly initialized."); Assert.IsFalse(target.IsSelected, "the 'IsSelected' property is not properly initialized."); Assert.AreEqual(string.Empty, target.FolderPath, "The property 'FolderPath' is not properly initialized."); Assert.AreEqual(string.Empty, target.NewName, "The property 'NewName' is not properly initialized."); }
protected override void ExecuteCore(SelectedItemCollection selection) { string newName = _newName; Folders.FixupRelativePath(ref newName); FolderAction action = new RenameFolderAction(_folder, newName); action.Completed += action_Completed; action.RunAsync(); }
public void NewNameTest() { RenameFolderAction target = new RenameFolderAction(); Assert.AreEqual <string>(string.Empty, target.NewName, "The property 'NewName' is not properly initialized."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The 'ConfigurationState' is not properly initialized."); string expected = "NewName"; string actual; target.NewName = expected; actual = target.NewName; Assert.AreEqual(expected, actual, "The property 'NewName' is not properly initialized."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The 'ConfigurationState' is not properly updated."); target.FolderPath = @"C:\Windows\System32\OldFolder"; Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The 'ConfigurationState' is not properly updated."); target.NewName = string.Empty; Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The 'ConfigurationState' doesn't revert back to 'MisConfigured' when set to string.Empty."); }
public void UserProfileNotificationTest() { RenameFolderAction target = new RenameFolderAction(); Assert.IsFalse(target.RefersToUserProfile, "The property 'RefersToUserProfile' is not properly initialized"); foreach (string folder in CommonData.userProfileRelatedFolders) { target.FolderPath = folder; Assert.IsTrue(target.RefersToUserProfile, folder + " should set 'RefersToUserProfile' to true."); } target.FolderPath = @"C:\Temp"; Assert.IsFalse(target.RefersToUserProfile); foreach (string folder in CommonData.otherFolders) { target.FolderPath = folder; Assert.IsFalse(target.RefersToUserProfile, folder + " should not set 'RefersToUserProfile' to true."); } }
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); }