diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs index bb2a78deb3..08a4fa117b 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -189,6 +189,42 @@ public void should_not_call_command_executor() { commandExecutor.Verify(c => c.execute(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); } + } + + public class when_install_location_is_empty : AutomaticUninstallerServiceSpecsBase + { + public override void Context() + { + base.Context(); + fileSystem.ResetCalls(); + registryKeys.Clear(); + registryKeys.Add(new RegistryApplicationKey + { + InstallLocation = string.Empty, + UninstallString = originalUninstallString, + HasQuietUninstall = false, + KeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinDirStat" + }); + packageInformation.RegistrySnapshot = new Registry("123", registryKeys); + } + + public override void Because() + { + service.run(packageResult, config); + } + + [Fact] + public void should_call_get_package_information() + { + packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once); + } + + [Fact] + public void should_call_command_executor() + { + var args = installerType.build_uninstall_command_arguments().trim_safe(); + commandExecutor.Verify(c => c.execute(expectedUninstallString, args, It.IsAny(), It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Once); + } } public class when_registry_location_does_not_exist : AutomaticUninstallerServiceSpecsBase diff --git a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs index e6e5046864..4e86036f51 100644 --- a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs +++ b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs @@ -68,7 +68,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) { this.Log().Debug(() => " Preparing uninstall key '{0}'".format_with(key.UninstallString)); - if (!_fileSystem.directory_exists(key.InstallLocation) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)) + if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)) { this.Log().Info(" Skipping auto uninstaller - The application appears to have been uninstalled already by other means."); this.Log().Debug(() => " Searched for install path '{0}' - found? {1}".format_with(key.InstallLocation.escape_curly_braces(), _fileSystem.directory_exists(key.InstallLocation)));