public void GivenPathSetItDoesNotAddPathToEnvironment() { var reporter = new BufferedReporter(); var toolsPath = new BashPathUnderHomeDirectory("/home/user", ".dotnet/tools"); var pathValue = @"/usr/bin"; var provider = new Mock <IEnvironmentProvider>(MockBehavior.Strict); var fileSystem = new FileSystemMockBuilder().Build().File; provider .Setup(p => p.GetEnvironmentVariable("PATH")) .Returns(pathValue + ":" + toolsPath.Path); var environmentPath = new OsxBashEnvironmentPath( toolsPath, reporter, provider.Object, fileSystem); environmentPath.AddPackageExecutablePathToUserPath(); reporter.Lines.Should().BeEmpty(); fileSystem .Exists(OsxBashEnvironmentPath.DotnetCliToolsPathsDPath) .Should() .Be(false); }
public void GivenPathNotSetItAddsToEnvironment() { var reporter = new BufferedReporter(); var toolsPath = new BashPathUnderHomeDirectory("/home/user", ".dotnet/tools"); var pathValue = @"/usr/bin"; var provider = new Mock <IEnvironmentProvider>(MockBehavior.Strict); IFileSystem fileSystem = new FileSystemMockBuilder().Build(); fileSystem.Directory.CreateDirectory("/etc/paths.d"); provider .Setup(p => p.GetEnvironmentVariable("PATH")) .Returns(pathValue); var environmentPath = new OsxBashEnvironmentPath( toolsPath, reporter, provider.Object, fileSystem.File); environmentPath.AddPackageExecutablePathToUserPath(); reporter.Lines.Should().BeEmpty(); fileSystem .File .ReadAllText(OsxBashEnvironmentPath.DotnetCliToolsPathsDPath) .Should() .Be(toolsPath.PathWithTilde); }