public void Should_Resolve_Tool_From_Environment_Variable_Gracefully_Proceed_If_FileSystem_Throw_Exception()
            {
                // Given
                var fixture = new ToolResolutionStrategyFixture();

                fixture.Environment.SetEnvironmentVariable("PATH", "/Working/fail:/Working/temp");
                fixture.FileSystem.CreateFile("/Working/temp/tool.exe");

                var fileSystem = Substitute.For <IFileSystem>();

                fileSystem.GetFile(Arg.Any <FilePath>()).Returns(call =>
                {
                    var path = call.Arg <FilePath>();
                    if (path.FullPath == "/Working/fail/tool.exe")
                    {
                        throw new Exception("Error!");
                    }
                    return(fixture.FileSystem.GetFile(path));
                });

                var strategy = new ToolResolutionStrategy(fileSystem, fixture.Environment, fixture.Globber, fixture.Configuration, new NullLog());

                // When
                var result = strategy.Resolve(fixture.Repository, "tool.exe");

                // Then
                Assert.Equal("/Working/temp/tool.exe", result.FullPath);
                fileSystem.Received().GetFile(Arg.Is <FilePath>(p => p.FullPath == "/Working/fail/tool.exe"));
                fileSystem.Received().GetFile(Arg.Is <FilePath>(p => p.FullPath == "/Working/temp/tool.exe"));
            }
Exemple #2
0
        public FilePath Resolve(IEnumerable <string> toolExeNames)
        {
            var strategy = new ToolResolutionStrategy(FileSystem, Environment, Globber, Configuration, new NullLog());

            return(strategy.Resolve(Repository, toolExeNames));
        }
Exemple #3
0
        public FilePath Resolve(string name)
        {
            var strategy = new ToolResolutionStrategy(FileSystem, Environment, Globber, Configuration, new NullLog());

            return(strategy.Resolve(Repository, name));
        }