public void TestUserControlEditInstalledCheckDisplay() { Console.WriteLine("TestUserControlEditInstalledCheckDisplay"); // a configuration with a checkbox control ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); ControlEdit edit = new ControlEdit(); edit.Text = "4"; edit.Id = "edit1"; edit.Check = ControlCheckType.display; setupConfiguration.Children.Add(edit); // an installed check that is always false InstalledCheckRegistry check = new InstalledCheckRegistry(); check.path = @"SOFTWARE\KeyDoesntExist"; check.comparison = installcheckregistry_comparison.exists; edit.Children.Add(check); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b [edit1]5"; cmd.required_install = true; setupConfiguration.Children.Add(cmd); // save config file string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // execute dotNetInstaller Assert.AreEqual(5, dotNetInstallerExeUtils.Run(configFilename)); File.Delete(configFilename); }
public void TestUserControlCheckboxInstallCheck() { Console.WriteLine("TestUserControlCheckboxInstallCheck"); // a configuration with a checkbox control which has an installed check that disables it ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); // a checkbox that changes are return value ControlCheckBox checkbox = new ControlCheckBox(); checkbox.UncheckedValue = "3"; checkbox.CheckedValue = "4"; checkbox.Checked = true; checkbox.Id = "checkbox1"; setupConfiguration.Children.Add(checkbox); // an installed check that is always false InstalledCheckRegistry check = new InstalledCheckRegistry(); check.path = @"SOFTWARE\KeyDoesntExist"; check.comparison = installcheckregistry_comparison.exists; checkbox.Children.Add(check); // command that depends on the value of checkbox1 ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b [checkbox1]5"; cmd.required_install = true; setupConfiguration.Children.Add(cmd); // save config file string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // execute dotNetInstaller, this checkbox is disabled, so all runs ignore checkbox1 value Assert.AreEqual(5, dotNetInstallerExeUtils.Run(configFilename)); checkbox.Checked = false; configFile.SaveAs(configFilename); Assert.AreEqual(5, dotNetInstallerExeUtils.Run(configFilename)); checkbox.Checked = true; checkbox.CheckedValue = "0"; configFile.SaveAs(configFilename); Assert.AreEqual(5, dotNetInstallerExeUtils.Run(configFilename)); File.Delete(configFilename); }
public void TestNotAutoClosesAfterInstallWhenComponentInstallFails() { Console.WriteLine("TestNotAutoClosesAfterInstallWhenComponentInstallFails"); // configuration with a component that will run and fail and so dni will not auto close ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); setupConfiguration.auto_start = true; setupConfiguration.auto_close_if_installed = true; setupConfiguration.installation_completed = null; setupConfiguration.failed_exec_command_continue = string.Empty; configFile.Children.Add(setupConfiguration); ComponentCmd cmd = new ComponentCmd(); cmd.command = "cmd.exe /C exit /b 1"; cmd.required_install = true; cmd.supports_install = true; setupConfiguration.Children.Add(cmd); InstalledCheckRegistry check = new InstalledCheckRegistry(); check.path = @"SOFTWARE\KeyDoesntExists"; check.comparison = installcheckregistry_comparison.exists; cmd.Children.Add(check); string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // will not auto close since all required components failed to install Assert.AreNotEqual(0, dotNetInstallerExeUtils.Run(configFilename)); dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename); options.quiet = false; Process p = dotNetInstallerExeUtils.Detach(options); Assert.IsFalse(p.WaitForExit(3 * 1000)); p.Kill(); p.WaitForExit(); Assert.AreEqual(-1, p.ExitCode); File.Delete(configFilename); }
public void TestPromptForOptionalSet() { Console.WriteLine("TestPromptForOptionalSet"); // configuration with a required and optional component // will prompt for the optional component, auto-start and install it string markerFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); setupConfiguration.auto_start = true; setupConfiguration.auto_close_if_installed = true; setupConfiguration.prompt_for_optional_components = true; setupConfiguration.installation_completed = string.Empty; setupConfiguration.installation_none = string.Empty; configFile.Children.Add(setupConfiguration); // dummy required component ComponentCmd component_required = new ComponentCmd(); setupConfiguration.Children.Add(component_required); component_required.required_install = true; component_required.supports_install = true; component_required.command = "dummy"; InstalledCheckRegistry check_required = new InstalledCheckRegistry(); check_required.fieldname = string.Empty; check_required.path = "SOFTWARE"; check_required.comparison = installcheckregistry_comparison.exists; component_required.Children.Add(check_required); // dummy optional component ComponentCmd component_optional = new ComponentCmd(); setupConfiguration.Children.Add(component_optional); component_optional.required_install = false; component_optional.supports_install = true; component_optional.command = string.Format("cmd.exe /C dir > \"{0}\"", markerFilename); InstalledCheckFile check_optional = new InstalledCheckFile(); check_optional.filename = markerFilename; check_optional.comparison = installcheckfile_comparison.exists; component_optional.Children.Add(check_optional); string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFilename); configFile.SaveAs(configFilename); // will not auto close since all components installed successfully dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename); options.quiet = false; options.autostart = true; Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options)); Assert.IsTrue(File.Exists(markerFilename)); File.Delete(configFilename); File.Delete(markerFilename); }