public static InstallJob CreateInstallJob(string product, FileSystem fileSystem, FileSystemCommandsBoundary commands, string prefix, Func <ProductInstallationMetaData, bool> productMatcher) { var chefProduct = new ChefProduct(product, new InstalledProductsFinder(), new ProductInstaller(fileSystem, new ProcessExecutor(() => new ProcessBoundary()), commands, prefix, $@"{ServerSettings.Instance.InstallRoot}\opscode"), productMatcher); return(new InstallJob(chefProduct, SystemClock.Instance)); }
public void InstallOrUpgrade_ShouldUninstallExistingProductThenInstallNewOne() { var chefInstallationMetaData = CreateProductInstallationMetaData("1.2.3"); var finder = new FakeInstalledProductsFinder(chefInstallationMetaData); var installer = new FakeProductInstaller(finder); var product = new ChefProduct("chef", finder, installer, InstalledProductsFinder.IsChefClient); const string versionInstalled = "15.1.2"; product.InstallOrUpgrade(versionInstalled, new FakeMessagePresenter()); installer.ProductCodeUninstalled.Should() .Be(chefInstallationMetaData.Parent, "because since the product is already installed, we should uninstall it"); installer.VersionInstalled.Should().Be(versionInstalled); }