public void Should_Throw_If_Tool_Name_Is_Null() { // Given var fixture = new ToolResolutionStrategyFixture(); // When var result = Record.Exception(() => fixture.Resolve((string)null)); // Then AssertEx.IsArgumentNullException(result, "tool"); }
public void Should_Return_Null_If_ToolExeNames_Could_Not_Be_Resolved() { // Given var fixture = new ToolResolutionStrategyFixture(); // When var result = fixture.Resolve(new[] { "tool.exe", "dotnet-tool", "dotnet-tool.exe" }); // Then Assert.Null(result); }
public void Should_Return_Null_If_Tool_Could_Not_Be_Resolved() { // Given var fixture = new ToolResolutionStrategyFixture(); // When var result = fixture.Resolve("tool.exe"); // Then Assert.Null(result); }
public void Should_Throw_If_ToolExeNames_Is_Empty(string tool) { // Given var fixture = new ToolResolutionStrategyFixture(); // When var result = Record.Exception(() => fixture.Resolve(new[] { tool })); // Then AssertEx.IsArgumentException(result, "toolExeNames", "Tool names cannot be empty."); }
public void Should_Throw_If_Tool_Repository_Is_Null() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.Repository = null; // When var result = Record.Exception(() => fixture.Resolve("tool.exe")); // Then AssertEx.IsArgumentNullException(result, "repository"); }
public void Should_Throw_If_File_System_Is_Null() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.FileSystem = null; // When var result = Record.Exception(() => fixture.Resolve("tool.exe")); // Then AssertEx.IsArgumentNullException(result, "fileSystem"); }
public void Should_Throw_If_Globber_Is_Null() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.Globber = null; // When var result = Record.Exception(() => fixture.Resolve("tool.exe")); // Then Assert.IsArgumentNullException(result, "globber"); }
public void Should_Resolve_ToolExeNames_From_Environment_Variable_If_Not_Present_In_Tools_Directory() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.FileSystem.CreateFile("/Working/temp/dotnet-tool.exe"); fixture.Environment.SetEnvironmentVariable("PATH", "/Working/temp"); // When var result = fixture.Resolve(new[] { "tool.exe", "dotnet-tool", "dotnet-tool.exe" }); // Then Assert.Equal("/Working/temp/dotnet-tool.exe", result.FullPath); }
public void Should_Prefer_ToolExeNames_With_Windows_Platform_Affinity_When_Windows_Environment(string windowsTool) { // Given var fixture = new ToolResolutionStrategyFixture(FakeEnvironment.CreateWindowsEnvironment()); fixture.Repository.Register("./tool"); fixture.Repository.Register($"./{windowsTool}"); // When var result = fixture.Resolve(new[] { "tool", windowsTool }); // Then Assert.Equal($"C:/Working/{windowsTool}", result.FullPath); }
public void Should_Return_Tool_From_Tools_Directory_If_Not_Present_In_Repository() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.FileSystem.CreateFile("/Working/tools/tool.exe"); fixture.FileSystem.CreateFile("/Working/temp/tool.exe"); fixture.Environment.SetEnvironmentVariable("PATH", "/Working/temp"); // When var result = fixture.Resolve("tool.exe"); // Then Assert.Equal("/Working/tools/tool.exe", result.FullPath); }
public void Should_Resolve_ToolExeNames_From_Tools_Directory_Specified_In_Configuration_If_Not_Present_In_Repository() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.Configuration.SetValue(Constants.Paths.Tools, "./stuff"); fixture.FileSystem.CreateFile("/Working/stuff/dotnet-tool.exe"); fixture.FileSystem.CreateFile("/Working/temp/tool.exe"); fixture.Environment.SetEnvironmentVariable("PATH", "/Working/temp"); // When var result = fixture.Resolve(new[] { "tool.exe", "dotnet-tool", "dotnet-tool.exe" }); // Then Assert.Equal("/Working/stuff/dotnet-tool.exe", result.FullPath); }
public void Should_Prefer_To_Resolve_ToolExeNames_From_Repository_If_Possible() { // Given var fixture = new ToolResolutionStrategyFixture(); fixture.Repository.Register("./dotnet-tool.exe"); fixture.FileSystem.CreateFile("/Working/tools/tool.exe"); fixture.FileSystem.CreateFile("/Working/temp/tool.exe"); fixture.Environment.SetEnvironmentVariable("PATH", "/Working/temp"); // When var result = fixture.Resolve(new[] { "tool.exe", "dotnet-tool", "dotnet-tool.exe" }); // Then Assert.Equal("/Working/dotnet-tool.exe", result.FullPath); }