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 GivenManifestInspectorWhenCalledFromRedirectCommandItPrintsTheTable()
        {
            var command = new ToolListCommand(result: _parseResult,
                                              toolListLocalCommand: _defaultToolListLocalCommand);

            _defaultToolListLocalCommand.Execute();
            _reporter.Lines.Should().Contain(l => l.Contains("package.id"));
            _reporter.Lines.Should().Contain(l => l.Contains("2.1.4"));
            _reporter.Lines.Should().Contain(l => l.Contains(_testManifestPath));
            _reporter.Lines.Should().Contain(l => l.Contains("package-name"));
        }
Пример #3
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"));
        }