public void IsInstalled() { // Sanity check - not expecting the exe directory to exist to start with var installationBaseDir = Path.Combine(TestContext.DeploymentDirectory, TestContext.TestName); Directory.Exists(installationBaseDir).Should().BeFalse(); var installer = new DaemonInstaller(logger, installationBaseDir, "c:\\dummy", envSettingsMock.Object); // 1. No directory or file -> false installer.IsInstalled().Should().BeFalse(); // 2. Directory exists but not file Directory.CreateDirectory(installer.InstallationPath); installer.IsInstalled().Should().BeFalse(); // 3. Directory and file exist -> true var subDir = Path.Combine(installer.InstallationPath, "sub1", "sub2"); Directory.CreateDirectory(subDir); var javaExePath = Path.Combine(subDir, "java.exe"); File.WriteAllText(javaExePath, "junk"); installer.IsInstalled().Should().BeTrue(); }
public void SetUp() { logger = new TestLogger(logToConsole: true); tempPath = Path.Combine(TestContext.DeploymentDirectory, Path.GetRandomFileName()); storagePath = Path.Combine(TestContext.DeploymentDirectory, Path.GetRandomFileName()); Directory.CreateDirectory(tempPath); Directory.CreateDirectory(storagePath); installer = new DaemonInstaller(logger, storagePath, tempPath); logger.Reset(); // clear any messages logged during construction }
public void DownloadUrlInEnvironmentVar_NotSet_DefaultUsed() { // Arrange - make sure the variable is not set SetUrlEnvironmentVariable(null); // Act var installer = new DaemonInstaller(logger, "c:\\storage", "d:\\temp", envSettingsMock.Object); // Assert installer.DownloadUrl.Should().Be(VSIX.DaemonInstaller.DefaultDownloadUrl); installer.DaemonVersion.Should().Be(VSIX.DaemonInstaller.DefaultDaemonVersion); installer.InstallationPath.Should().Be($"c:\\storage\\sonarlint-daemon-{VSIX.DaemonInstaller.DefaultDaemonVersion}-windows"); installer.ZipFilePath.Should().Be($"d:\\temp\\sonarlint-daemon-{VSIX.DaemonInstaller.DefaultDaemonVersion}-windows.zip"); }
public void DownloadUrlInEnvironmentVar_Valid_UseSupplied() { // Arrange SetUrlEnvironmentVariable( "https://repox.jfrog.io/repox/sonarsource/org/sonarsource/sonarlint/core/sonarlint-daemon/4.3.0.2450/sonarlint-daemon-4.3.0.2450-windows.zip"); // Act var installer = new DaemonInstaller(logger, "c:\\storagePath\\", "d:\\tempPath\\", envSettingsMock.Object); // Assert installer.DownloadUrl.Should().Be("https://repox.jfrog.io/repox/sonarsource/org/sonarsource/sonarlint/core/sonarlint-daemon/4.3.0.2450/sonarlint-daemon-4.3.0.2450-windows.zip"); installer.DaemonVersion.Should().Be("4.3.0.2450"); installer.InstallationPath.Should().Be("c:\\storagePath\\sonarlint-daemon-4.3.0.2450-windows"); installer.ZipFilePath.Should().Be("d:\\tempPath\\sonarlint-daemon-4.3.0.2450-windows.zip"); }
public void DownloadUrlInEnvironmentVar_NotSet_DefaultUsed() { using (var scope = new EnvironmentVariableScope()) { // Arrange - make sure the variable is not set scope.SetVariable(VSIX.DaemonInstaller.SonarLintDownloadUrlEnvVar, ""); // Act var installer = new DaemonInstaller(logger, "c:\\storage", "d:\\temp"); // Assert installer.DownloadUrl.Should().Be(VSIX.DaemonInstaller.DefaultDownloadUrl); installer.DaemonVersion.Should().Be(VSIX.DaemonInstaller.DefaultDaemonVersion); installer.InstallationPath.Should().Be($"c:\\storage\\sonarlint-daemon-{VSIX.DaemonInstaller.DefaultDaemonVersion}-windows"); installer.ZipFilePath.Should().Be($"d:\\temp\\sonarlint-daemon-{VSIX.DaemonInstaller.DefaultDaemonVersion}-windows.zip"); } }