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 OSXEnvironmentPath( toolsPath, reporter, provider.Object, fileSystem.File); environmentPath.AddPackageExecutablePathToUserPath(); reporter.Lines.Should().BeEmpty(); fileSystem .File .ReadAllText(OSXEnvironmentPath.DotnetCliToolsPathsDPath) .Should() .Be(toolsPath.PathWithTilde); }
public void GivenEnvironmentAndReporterItCanPrintOutInstructionToAddPath() { var fakeReporter = new FakeReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( @"~/executable/path", @"/Users/name/executable/path", fakeReporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", "" } }), FakeFile.Empty); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); // similar to https://code.visualstudio.com/docs/setup/mac fakeReporter.Message.Should().Be( $"Cannot find the tools executable path. Please ensure /Users/name/executable/path is added to your PATH.{Environment.NewLine}" + $"If you are using bash, You can do this by running the following command:{Environment.NewLine}{Environment.NewLine}" + $"cat << EOF >> ~/.bash_profile{Environment.NewLine}" + $"# Add .NET Core SDK tools{Environment.NewLine}" + $"export PATH=\"$PATH:/Users/name/executable/path\"{Environment.NewLine}" + $"EOF"); }
public void GivenEnvironmentAndReporterItPrintsNothingWhenenvironmentExists(string existingPath) { var fakeReporter = new FakeReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( new BashPathUnderHomeDirectory("/myhome", "executable/path"), fakeReporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", existingPath } }), FakeFile.Empty); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); fakeReporter.Message.Should().BeEmpty(); }
public void GivenEnvironmentAndReporterItPrintsNothingWhenenvironmentExists(string existingPath) { var fakeReporter = new FakeReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( @"~/executable/path", @"/Users/name/executable/path", fakeReporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", existingPath } }), FakeFile.Empty); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); fakeReporter.Message.Should().BeEmpty(); }
public void GivenAddPackageExecutablePathToUserPathJustRunItPrintsInstructionToLogout() { var reporter = new BufferedReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( new BashPathUnderHomeDirectory("/myhome", "executable/path"), reporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", @"" } }), FakeFile.Empty); osxEnvironmentPath.AddPackageExecutablePathToUserPath(); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); reporter.Lines.Should().Equal(CommonLocalizableStrings.EnvironmentPathOSXNeedReopen); }
public void GivenAddPackageExecutablePathToUserPathJustRunItPrintsInstructionToLogout() { var fakeReporter = new FakeReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( new BashPathUnderHomeDirectory("/myhome", "executable/path"), fakeReporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", @"" } }), FakeFile.Empty); osxEnvironmentPath.AddPackageExecutablePathToUserPath(); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); fakeReporter.Message.Should().Be( "Since you just installed the .NET Core SDK, you will need to reopen terminal before running the tool you installed."); }
public void GivenEnvironmentAndReporterItCanPrintOutInstructionToAddPath() { var reporter = new BufferedReporter(); var osxEnvironmentPath = new OSXEnvironmentPath( new BashPathUnderHomeDirectory("/myhome", "executable/path"), reporter, new FakeEnvironmentProvider( new Dictionary <string, string> { { "PATH", "" } }), FakeFile.Empty); osxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist(); // similar to https://code.visualstudio.com/docs/setup/mac reporter.Lines.Should().Equal( string.Format( CommonLocalizableStrings.EnvironmentPathOSXManualInstruction, "/myhome/executable/path", "/myhome/executable/path")); }
public void GivenPathSetItPrintsNothing(string toolsDiretoryOnPath) { var reporter = new BufferedReporter(); var toolsPath = new BashPathUnderHomeDirectory("/home/user", ".dotnet/tools"); var pathValue = @"/usr/bin"; var provider = new Mock <IEnvironmentProvider>(MockBehavior.Strict); provider .Setup(p => p.GetEnvironmentVariable("PATH")) .Returns(pathValue + ":" + toolsDiretoryOnPath); var environmentPath = new OSXEnvironmentPath( toolsPath, reporter, provider.Object, FileSystemMockBuilder.Empty.File); environmentPath.PrintAddPathInstructionIfPathDoesNotExist(); reporter.Lines.Should().BeEmpty(); }
public void GivenPathNotSetAndProfileExistsItPrintsReopenMessage() { var reporter = new BufferedReporter(); var toolsPath = new BashPathUnderHomeDirectory("/home/user", ".dotnet/tools"); var pathValue = @"/usr/bin"; var provider = new Mock <IEnvironmentProvider>(MockBehavior.Strict); provider .Setup(p => p.GetEnvironmentVariable("PATH")) .Returns(pathValue); var environmentPath = new OSXEnvironmentPath( toolsPath, reporter, provider.Object, new FileSystemMockBuilder() .AddFile(OSXEnvironmentPath.DotnetCliToolsPathsDPath, "") .Build() .File); environmentPath.PrintAddPathInstructionIfPathDoesNotExist(); reporter.Lines.Should().Equal(CommonLocalizableStrings.EnvironmentPathOSXNeedReopen); }
public void GivenPathNotSetItPrintsManualInstructions() { var reporter = new BufferedReporter(); var toolsPath = new BashPathUnderHomeDirectory("/home/user", ".dotnet/tools"); var pathValue = @"/usr/bin"; var provider = new Mock <IEnvironmentProvider>(MockBehavior.Strict); provider .Setup(p => p.GetEnvironmentVariable("PATH")) .Returns(pathValue); var environmentPath = new OSXEnvironmentPath( toolsPath, reporter, provider.Object, FileSystemMockBuilder.Empty.File); environmentPath.PrintAddPathInstructionIfPathDoesNotExist(); reporter.Lines.Should().Equal( string.Format( CommonLocalizableStrings.EnvironmentPathOSXManualInstructions, toolsPath.Path)); }