public void ValidateDataTest() { CreateShortcutAction target = new CreateShortcutAction(); Assert.AreEqual(GenericAction.ConfigurationStates.NotConfigured, target.ConfigurationState); target.Target = @"C:\test"; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.ShortcutName = "test"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.Target = @"C:\test\"; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.Target = @"C:\test"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.IsPersoLocation = true; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.PersoLocation = @"C:\test\test"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); target.PersoLocation = @"C:\test\test\"; Assert.AreEqual(GenericAction.ConfigurationStates.Misconfigured, target.ConfigurationState); target.PersoLocation = @"C:\test\test"; Assert.AreEqual(GenericAction.ConfigurationStates.Configured, target.ConfigurationState); }
public void GetXMLActionTest() { CreateShortcutAction target = new CreateShortcutAction(); target.Target = @"C:\Windows\System32\test.exe"; target.ShortcutName = "Raccourcis pour test.exe"; target.IsDesktopLocation = true; target.DesktopTarget = 0; target.Description = "Description pour le test"; target.Icon = "test"; target.Arguments = "/SetParameters"; target.WorkingDirectory = @"C:\Windows\temp"; target.WindowStyle = 0; target.AbortIfTargetDontExist = true; string expected = "<Action>\r\n<ElementType>CustomActions.CreateShortcutAction</ElementType>\r\n" + "<Target>" + @"C:\Windows\System32\test.exe" + "</Target>\r\n" + "<ShortcutName>" + "Raccourcis pour test.exe" + "</ShortcutName>\r\n" + "<Description>" + "Description pour le test" + "</Description>\r\n" + "<Icon>" + "test" + "</Icon>\r\n" + "<Arguments>" + "/SetParameters" + "</Arguments>\r\n" + "<WorkingDirectory>" + @"C:\Windows\temp" + "</WorkingDirectory>\r\n" + "<WindowStyle>" + "0" + "</WindowStyle>\r\n" + "<DesktopTarget>" + "0" + "</DesktopTarget>\r\n" + "<IsDesktopLocation>" + "true" + "</IsDesktopLocation>\r\n" + "<IsPersoLocation>" + "false" + "</IsPersoLocation>\r\n" + "<PersoLocation>" + String.Empty + "</PersoLocation>\r\n" + "<AbortIfTargetDontExist>" + "true" + "</AbortIfTargetDontExist>\r\n</Action>"; string actual = target.GetXMLAction(); Assert.AreEqual(expected, actual, true, "XML not properly generated"); target.IsPersoLocation = true; actual = target.GetXMLAction(); Assert.IsTrue(target.IsPersoLocation, "The property 'IsPersoLocation' is not properly updated"); Assert.IsFalse(target.IsDesktopLocation, "The property 'IsDesktopLocation' is not properly updated"); target.DesktopTarget = 1; actual = target.GetXMLAction(); Assert.IsTrue(actual.Contains("<DesktopTarget>" + "1" + "</DesktopTarget>\r\n"), "The property 'DesktopTarget' is not properly updated"); target.WindowStyle = 1; actual = target.GetXMLAction(); Assert.IsTrue(actual.Contains("<WindowStyle>" + "1" + "</WindowStyle>\r\n"), "The property 'WindowStyle' is not properly updated"); target.WindowStyle = 2; actual = target.GetXMLAction(); Assert.IsTrue(actual.Contains("<WindowStyle>" + "2" + "</WindowStyle>\r\n"), "The property 'WindowStyle' is not properly updated"); }
private void DefaultValueForProperties() { CreateShortcutAction target = new CreateShortcutAction(); 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(GenericAction.ConfigurationStates.NotConfigured, target.ConfigurationState); Assert.IsFalse(target.RefersToUserProfile); Assert.AreEqual(String.Empty, target.Target); Assert.AreEqual(String.Empty, target.ShortcutName); Assert.IsTrue(target.IsDesktopLocation); Assert.AreEqual(0, target.DesktopTarget); Assert.IsFalse(target.IsPersoLocation); Assert.AreEqual(String.Empty, target.PersoLocation); Assert.AreEqual(String.Empty, target.Description); Assert.AreEqual(String.Empty, target.Icon); Assert.AreEqual(String.Empty, target.Arguments); Assert.AreEqual(String.Empty, target.WorkingDirectory); Assert.AreEqual(0, target.WindowStyle); Assert.IsTrue(target.AbortIfTargetDontExist); }
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); }