public void KillProcessActionConstructorTest() { KillProcessAction target = new KillProcessAction(); 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.ProcessName, "The property 'ProcessName' is not properly initialized"); }
public void ValidateDataTest() { KillProcessAction target = new KillProcessAction(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The property 'ConfigurationState' is not properly initialized"); target.ProcessName = "notepad.exe"; Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated"); target.ProcessName = string.Empty; Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' doesn't revert back to Misconfigured"); }
public void GetXMLActionTest() { KillProcessAction target = new KillProcessAction(); target.ProcessName = "notepad.exe"; string expected = "<Action>\r\n<ElementType>CustomActions.KillProcessAction</ElementType>\r\n<ProcessName>" + target.ProcessName + "</ProcessName>\r\n</Action>"; string actual; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, "The 'GetXMLAction' method doesn't return the good string"); target.ProcessName = " notepad.exe "; actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, "The 'GetXMLAction' method doesn't return the good string"); }
public void ProcessNameTest() { KillProcessAction target = new KillProcessAction(); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.NotConfigured, "The property 'ConfigurationState' is not properly initialized"); string expected = "notepad.exe"; string actual; target.ProcessName = expected; actual = target.ProcessName; Assert.AreEqual(expected, actual, "The property 'ProcessName' is not properly initialized."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated"); target.ProcessName = string.Empty; actual = target.ProcessName; Assert.AreEqual(string.Empty, actual, "The property 'ProcessName' cannot be set to string.Empty."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Misconfigured, "The property 'ConfigurationState' is not properly updated"); target.ProcessName = @" notepad.exe "; actual = target.ProcessName; Assert.AreEqual(expected, actual, "The property 'ProcessName' is not not properly trimed."); Assert.IsTrue(target.ConfigurationState == GenericAction.ConfigurationStates.Configured, "The property 'ConfigurationState' is not properly updated"); }
private static IAction GetAction(ActionModel action) { IAction actionInstance = null; switch (action.Action) { case ActionType.WriteFile: actionInstance = new WriteFileAction(); break; case ActionType.IF: actionInstance = new IFAction(); break; case ActionType.HttpRequest: actionInstance = new HttpRequestAction(); break; case ActionType.Shutdown: actionInstance = new ShutdownAction(); break; case ActionType.StartProcess: actionInstance = new StartProcessAction(); break; case ActionType.OpenURL: actionInstance = new OpenURLAction(); break; case ActionType.Snipping: actionInstance = new SnippingAction(); break; case ActionType.DeleteFile: actionInstance = new DeleteFileAction(); break; case ActionType.SoundPlay: actionInstance = new SoundPlayAction(); break; case ActionType.GetIPAddress: actionInstance = new GetIPAddressAction(); break; case ActionType.Keyboard: actionInstance = new KeyboardAction(); break; case ActionType.SystemNotification: actionInstance = new SystemNotificationAction(); break; case ActionType.DownloadFile: actionInstance = new DownloadFileAction(); break; case ActionType.Dialog: actionInstance = new DialogAction(); break; case ActionType.Delay: actionInstance = new DelayAction(); break; case ActionType.Loops: actionInstance = new LoopsAction(); break; case ActionType.KillProcess: actionInstance = new KillProcessAction(); break; case ActionType.SetDeviceVolume: actionInstance = new SetDeviceVolumeAction(); break; case ActionType.Regex: actionInstance = new RegexAction(); break; case ActionType.ReadFile: actionInstance = new ReadFileAction(); break; case ActionType.JsonDeserialize: actionInstance = new JsonDeserializeAction(); break; } if (actionInstance != null) { return(actionInstance); } return(null); }
public void KillProcessActionText() { KillProcessAction target = new KillProcessAction(); target.ProcessName = null; }
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); }