public void GivenAToolPathItPassesToolPathToStoreFactoryFromRedirectCommand()
        {
            var store = new Mock <IToolPackageStoreQuery>(MockBehavior.Strict);

            store
            .Setup(s => s.EnumeratePackages())
            .Returns(new IToolPackage[0]);

            var toolPath = Path.GetTempPath();
            var result   = Parser.Instance.Parse("dotnet tool list " + $"--tool-path {toolPath}");
            var toolListGlobalOrToolPathCommand = new ToolListGlobalOrToolPathCommand(
                result["dotnet"]["tool"]["list"],
                result,
                toolPath1 =>
            {
                AssertExpectedToolPath(toolPath1, toolPath);
                return(store.Object);
            },
                _reporter);

            var toolListCommand = new ToolListCommand(
                result["dotnet"]["tool"]["list"],
                result,
                toolListGlobalOrToolPathCommand);

            toolListCommand.Execute().Should().Be(0);

            _reporter.Lines.Should().Equal(EnumerateExpectedTableLines(store.Object));
        }
예제 #2
0
        public void WhenRunWithBothGlobalAndLocalShowErrorMessage()
        {
            var result = Parser.Instance.Parse($"dotnet tool list --local --tool-path /test/path");

            var toolInstallCommand = new ToolListCommand(
                result);

            Action a = () => toolInstallCommand.Execute();

            a.ShouldThrow <GracefulException>().And.Message
            .Should().Contain(
                string.Format(LocalizableStrings.ListToolCommandInvalidGlobalAndLocalAndToolPath,
                              "local tool-path"));
        }