public void WhenRunWithGlobalAndToolManifestShowErrorMessage() { var result = Parser.Instance.Parse($"dotnet tool uninstall -g --tool-manifest folder/my-manifest.format {PackageId}"); var toolUninstallCommand = new ToolUninstallCommand(result); Action a = () => toolUninstallCommand.Execute(); a.ShouldThrow <GracefulException>().And.Message .Should().Contain(Tools.Tool.Common.LocalizableStrings.OnlyLocalOptionSupportManifestFileOption); }
public void WhenRunWithBothGlobalAndLocalShowErrorMessage() { var result = Parser.Instance.Parse($"dotnet tool uninstall --local --tool-path /tmp/folder {PackageId}"); var toolUninstallCommand = new ToolUninstallCommand(result); Action a = () => toolUninstallCommand.Execute(); a.ShouldThrow <GracefulException>().And.Message .Should().Contain( string.Format(LocalizableStrings.UninstallToolCommandInvalidGlobalAndLocalAndToolPath, "local tool-path")); }
public void WhenRunFromToolUninstallRedirectCommandWithPackageIdItShouldRemoveFromManifestFile() { var parseResult = Parser.Instance.Parse($"dotnet tool uninstall {_packageIdDotnsay.ToString()}"); var toolUninstallLocalCommand = new ToolUninstallLocalCommand( parseResult, _toolManifestFinder, _toolManifestEditor, _reporter); var toolUninstallCommand = new ToolUninstallCommand( parseResult, toolUninstallLocalCommand: toolUninstallLocalCommand); toolUninstallCommand.Execute().Should().Be(0); _fileSystem.File.ReadAllText(_manifestFilePath).Should().Be(_entryRemovedJsonContent); }
public void WhenRunWithToolPathAndToolManifestShowErrorMessage() { var result = Parser.Instance.Parse( $"dotnet tool uninstall --tool-path /tmp/folder --tool-manifest folder/my-manifest.format {PackageId}"); var appliedCommand = result["dotnet"]["tool"]["uninstall"]; var toolUninstallCommand = new ToolUninstallCommand( appliedCommand, result); Action a = () => toolUninstallCommand.Execute(); a.ShouldThrow <GracefulException>().And.Message .Should().Contain(LocalizableStrings.OnlyLocalOptionSupportManifestFileOption); }
public void GivenAPackageWhenCallFromUninstallRedirectCommandItUninstalls() { CreateInstallCommand($"-g {PackageId}").Execute().Should().Be(0); _reporter .Lines .Last() .Should() .Contain(string.Format( InstallLocalizableStrings.InstallationSucceeded, ProjectRestorerMock.DefaultToolCommandName, PackageId, PackageVersion)); var packageDirectory = new DirectoryPath(Path.GetFullPath(_toolsDirectory)) .WithSubDirectories(PackageId, PackageVersion); var shimPath = Path.Combine( _shimsDirectory, ProjectRestorerMock.DefaultToolCommandName + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "")); _fileSystem.Directory.Exists(packageDirectory.Value).Should().BeTrue(); _fileSystem.File.Exists(shimPath).Should().BeTrue(); _reporter.Lines.Clear(); ParseResult result = Parser.Instance.Parse("dotnet tool uninstall " + $"-g {PackageId}"); (IToolPackageStore, IToolPackageStoreQuery, IToolPackageUninstaller) CreateToolPackageStoreAndUninstaller( DirectoryPath?directoryPath) { var store = new ToolPackageStoreMock( new DirectoryPath(_toolsDirectory), _fileSystem); var packageUninstaller = new ToolPackageUninstallerMock(_fileSystem, store); return(store, store, packageUninstaller); } var toolUninstallGlobalOrToolPathCommand = new ToolUninstallGlobalOrToolPathCommand( result, CreateToolPackageStoreAndUninstaller, (_) => new ShellShimRepository( new DirectoryPath(_shimsDirectory), fileSystem: _fileSystem, appHostShellShimMaker: new AppHostShellShimMakerMock(_fileSystem)), _reporter); var uninstallCommand = new ToolUninstallCommand( result, toolUninstallGlobalOrToolPathCommand: toolUninstallGlobalOrToolPathCommand); uninstallCommand.Execute().Should().Be(0); _reporter .Lines .Single() .Should() .Contain(string.Format( LocalizableStrings.UninstallSucceeded, PackageId, PackageVersion)); _fileSystem.Directory.Exists(packageDirectory.Value).Should().BeFalse(); _fileSystem.File.Exists(shimPath).Should().BeFalse(); }