public void TestGetInstallationWhenNotExists() { // GIVEN the installation is not present mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "a-version"))).Returns(false); // WHEN I get the installation DocumentationManager classUnderTest = new DocumentationManager(null, mockIFileUtility.Object, "a-dir"); DocumentationInstallation result = classUnderTest.GetInstallation("a-version"); // THEN the result is null Assert.IsNull(result); }
public void TestGetInstallationWhenExists() { // GIVEN the installation is present mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "a-version"))).Returns(true); // WHEN I get the installation DocumentationManager classUnderTest = new DocumentationManager(null, mockIFileUtility.Object, "a-dir"); DocumentationInstallation result = classUnderTest.GetInstallation("a-version"); // THEN the result is a valid DocumentationManager object Assert.AreEqual("a-version", result.Version); Assert.AreEqual(Path.Combine("a-dir", "a-version"), result.InstallationPath); }
private int Pull(PullOptions opts) { // If --list was specified, list installed versions and tell if documentation for that version is available locally if (opts.List) { PrintInstalledVersions(); return 0; } string version; ServerTier tier; string platform; if (opts.Version == null) { // If version info was omitted, set parameters to current project settings if (context.Project?.Runtime != null) { version = context.Project.Runtime.Version; platform = context.Project.Runtime.Platform; tier = context.Project.Runtime.Tier; } else { Console.Error.WriteLine(Output.Red($"Couldn't find a version to install. To download latest version use 'latest'")); return 1; } } else { version = opts.Version == "latest" ? installationManager.GetLatestDarkRiftVersion() : opts.Version; tier = opts.Pro ? ServerTier.Pro : ServerTier.Free; platform = opts.Platform; } // If --docs was specified, download documentation instead if (opts.Docs) { bool docsInstalled = documentationManager.GetInstallation(version) != null; if (docsInstalled && !opts.Force) { Console.WriteLine(Output.Green($"Documentation for DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force")); } else { if (documentationManager.Install(version, opts.Force) == null) { Console.Error.WriteLine(Output.Red($"Could not install the requested documentation.")); return 1; } } } else { bool versionInstalled = installationManager.GetInstallation(version, tier, platform) != null; if (versionInstalled && !opts.Force) { Console.WriteLine(Output.Green($"DarkRift {version} - {tier} (.NET {platform}) already installed! To force a reinstall use the option -f or --force")); } else { if (installationManager.Install(version, tier, platform, opts.Force) == null) { Console.Error.WriteLine(Output.Red($"Could not install the requested version.")); return 1; } } } return 0; }