Skip to content

Commit

Permalink
(chocolateyGH-14) rename registry exists to installer keys
Browse files Browse the repository at this point in the history
Rename the registry service `value_exists` to `installer_value_exists`
to clarify what it is doing.
  • Loading branch information
ferventcoder committed Jun 4, 2015
1 parent 7ae1939 commit 10b4f8c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override void Context()
packageResults.GetOrAdd("regular", packageResult);

fileSystem.Setup(f => f.directory_exists(registryKeys.FirstOrDefault().InstallLocation)).Returns(true);
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(true);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(true);
fileSystem.Setup(f => f.get_full_path(expectedUninstallString)).Returns(expectedUninstallString);
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public override void Context()
{
base.Context();
registryService.ResetCalls();
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
}

public override void Because()
Expand Down Expand Up @@ -264,7 +264,7 @@ public override void Context()
fileSystem.ResetCalls();
fileSystem.Setup(f => f.directory_exists(registryKeys.FirstOrDefault().InstallLocation)).Returns(false);
registryService.ResetCalls();
registryService.Setup(r => r.value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
registryService.Setup(r => r.installer_value_exists(registryKeys.FirstOrDefault().KeyPath, ApplicationParameters.RegistryValueInstallLocation)).Returns(false);
}

public override void Because()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
{
this.Log().Debug(() => " Preparing uninstall key '{0}'".format_with(key.UninstallString));

if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation))
if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.installer_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)));
this.Log().Debug(() => " Searched for registry key '{0}' value '{1}' - found? {2}".format_with(key.KeyPath.escape_curly_braces(), ApplicationParameters.RegistryValueInstallLocation, _registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)));
this.Log().Debug(() => " Searched for registry key '{0}' value '{1}' - found? {2}".format_with(key.KeyPath.escape_curly_braces(), ApplicationParameters.RegistryValueInstallLocation, _registryService.installer_value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)));
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public interface IRegistryService
Registry get_differences(Registry before, Registry after);
void save_to_file(Registry snapshot, string filePath);
Registry read_from_file(string filePath);
bool value_exists(string keyPath, string value);
bool installer_value_exists(string keyPath, string value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ public void save_to_file(Registry snapshot, string filePath)
_xmlService.serialize(snapshot, filePath);
}

public bool value_exists(string keyPath, string value)
public bool installer_value_exists(string keyPath, string value)
{
//todo: make this check less crazy...
return get_installer_keys().RegistryKeys.Any(k => k.KeyPath == keyPath);
}

Expand Down

0 comments on commit 10b4f8c

Please sign in to comment.