public void GivenFailedPackageInstallWhenRunWithPackageIdItShouldNotChangeManifestFile() { ParseResult result = Parser.Instance.Parse($"dotnet tool install non-exist"); var appliedCommand = result["dotnet"]["tool"]["install"]; Cli.CommandLine.Parser parser = Parser.Instance; var parseResult = parser.ParseFrom("dotnet tool", new[] { "install", "non-exist" }); var installLocalCommand = new ToolInstallLocalCommand( appliedCommand, parseResult, _toolPackageInstallerMock, _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _nugetGlobalPackagesFolder, _reporter); Action a = () => installLocalCommand.Execute(); a.ShouldThrow <GracefulException>() .And.Message.Should() .Contain(LocalizableStrings.ToolInstallationRestoreFailed); _fileSystem.File.ReadAllText(_manifestFilePath).Should() .Be(_jsonContent, "Manifest file should not be changed"); }
public void WhenRunWithExplicitManifestFileItShouldAddEntryToExplicitManifestFile() { var explicitManifestFilePath = Path.Combine(_temporaryDirectory, "subdirectory", "dotnet-tools.json"); _fileSystem.File.Delete(_manifestFilePath); _fileSystem.Directory.CreateDirectory(Path.Combine(_temporaryDirectory, "subdirectory")); _fileSystem.File.WriteAllText(explicitManifestFilePath, _jsonContent); ParseResult result = Parser.Instance.Parse( $"dotnet tool install {_packageIdA.ToString()} --tool-manifest {explicitManifestFilePath}"); var appliedCommand = result["dotnet"]["tool"]["install"]; Cli.CommandLine.Parser parser = Parser.Instance; var parseResult = parser.ParseFrom("dotnet tool", new[] { "install", _packageIdA.ToString(), "--tool-manifest", explicitManifestFilePath }); var installLocalCommand = new ToolInstallLocalCommand( appliedCommand, parseResult, _toolPackageInstallerMock, _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _nugetGlobalPackagesFolder, _reporter); installLocalCommand.Execute().Should().Be(0); _toolManifestFinder.Find(new FilePath(explicitManifestFilePath)).Should().HaveCount(1); }
public void WhenRunWithPrereleaseAndPackageVersionItShouldSucceed() { ParseResult result = Parser.Instance.Parse($"dotnet tool install {_packageIdA.ToString()} --prerelease"); var installLocalCommand = new ToolInstallLocalCommand( result, GetToolToolPackageInstallerWithPreviewInFeed(), _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _reporter); installLocalCommand.Execute().Should().Be(0); var manifestPackages = _toolManifestFinder.Find(); manifestPackages.Should().HaveCount(1); var addedPackage = manifestPackages.Single(); _localToolsResolverCache.TryLoad(new RestoredCommandIdentifier( addedPackage.PackageId, new NuGetVersion("2.0.1-preview1"), NuGetFramework.Parse(BundledTargetFramework.GetTargetFrameworkMoniker()), Constants.AnyRid, addedPackage.CommandNames.Single()), out RestoredCommand restoredCommand ).Should().BeTrue(); _fileSystem.File.Exists(restoredCommand.Executable.Value); }
public void WhenRunWithValidVersionRangeItShouldSucceed() { ParseResult result = Parser.Instance.Parse( $"dotnet tool install {_packageIdA.ToString()} --version 1.*"); var installLocalCommand = new ToolInstallLocalCommand( result, _toolPackageInstallerMock, _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _reporter); installLocalCommand.Execute().Should().Be(0); AssertDefaultInstallSuccess(); }
public void WhenRunWithValidVersionRangeItShouldSucceed() { ParseResult result = Parser.Instance.Parse( $"dotnet tool install {_packageIdA.ToString()} --version 1.*"); var appliedCommand = result["dotnet"]["tool"]["install"]; Cli.CommandLine.Parser parser = Parser.Instance; var parseResult = parser.ParseFrom("dotnet tool", new[] { "install", _packageIdA.ToString(), "--version", "1.*" }); var installLocalCommand = new ToolInstallLocalCommand( appliedCommand, parseResult, _toolPackageInstallerMock, _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _reporter); installLocalCommand.Execute().Should().Be(0); AssertDefaultInstallSuccess(); }
public void WhenRunWithExplicitManifestFileItShouldAddEntryToExplicitManifestFile() { var explicitManifestFilePath = Path.Combine(_temporaryDirectory, "subdirectory", "dotnet-tools.json"); _fileSystem.File.Delete(_manifestFilePath); _fileSystem.Directory.CreateDirectory(Path.Combine(_temporaryDirectory, "subdirectory")); _fileSystem.File.WriteAllText(explicitManifestFilePath, _jsonContent); ParseResult parseResult = Parser.Instance.Parse( $"dotnet tool install {_packageIdA.ToString()} --tool-manifest {explicitManifestFilePath}"); var installLocalCommand = new ToolInstallLocalCommand( parseResult, _toolPackageInstallerMock, _toolManifestFinder, _toolManifestEditor, _localToolsResolverCache, _reporter); installLocalCommand.Execute().Should().Be(0); _toolManifestFinder.Find(new FilePath(explicitManifestFilePath)).Should().HaveCount(1); }