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); }
public void TestInstallWhenDownloadFails() { // GIVEN the installation does not exist mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "a-version"))).Returns(false); // AND the installation is not available on the remote mockIRemoteRepository.Setup(r => r.DownloadDocumentationTo("a-version", Path.Combine("a-dir", "a-version"))) .Returns(false); // WHEN I install the version DocumentationManager classUnderTest = new DocumentationManager(mockIRemoteRepository.Object, mockIFileUtility.Object, "a-dir"); DocumentationInstallation result = classUnderTest.Install("a-version", false); // THEN null is returned Assert.IsNull(result); }
public void TestInstall() { // GIVEN the installation does not exist mockIFileUtility.Setup(f => f.DirectoryExists(Path.Combine("a-dir", "a-version"))).Returns(false); // AND the installation is available on the remote mockIRemoteRepository.Setup(r => r.DownloadDocumentationTo("a-version", Path.Combine("a-dir", "a-version"))) .Returns(true); // WHEN I install the version DocumentationManager classUnderTest = new DocumentationManager(mockIRemoteRepository.Object, mockIFileUtility.Object, "a-dir"); DocumentationInstallation result = classUnderTest.Install("a-version", false); // THEN the download was run mockIRemoteRepository.Verify(r => r.DownloadDocumentationTo("a-version", Path.Combine("a-dir", "a-version"))); // AND the installation returned is correct Assert.AreEqual("a-version", result.Version); Assert.AreEqual(Path.Combine("a-dir", "a-version"), result.InstallationPath); }
private int Docs(DocsOptions opts) { // If version provided is "latest", it is being replaced with currently most recent one if (opts.Version == "latest") { opts.Version = installationManager.GetLatestDarkRiftVersion(); } if (opts.Version == null) { // If version info was omitted, overwrite any parameters with current project settings if (context.Project?.Runtime != null) { opts.Version = context.Project.Runtime.Version; } else { Console.Error.WriteLine(Output.Red($"Couldn't find a version to download documentation. To download latest version 'latest'")); return(1); } } if (opts.Local) { DocumentationInstallation installation = documentationManager.GetInstallation(opts.Version); if (installation != null) { installation.Open(); } else { Console.Error.WriteLine(Output.Red($"Documentation not installed, consider running \"darkrift pull {opts.Version} --docs\"")); } } else if (opts.Version != null) { BrowserUtil.OpenTo($"https://darkriftnetworking.com/DarkRift2/Docs/{opts.Version}"); } return(0); }