dotnet-installer/test/dotnet.Tests/ParserTests/UninstallInstallToolParserTests.cs
William Lee 0598e6cb70
tool-path option -- "Session tool" (#8716)
* Change to escape string via XML

* tool-path option -- "Session tool"

From the beginning design, shim and packageInstaller take package location from constructor and don't have assumption anymore. From previous discussion, tool-path will simply change global location to the one user want, and everything else is the same.

However, this "override" need to happen during the call, that means InstallToolCommand will create different shim and packageInstaller object according to the tool-path during the call instead of constructor DI.

* global package location change

* block of leading dot as command name

* Localization of tool-path option
2018-03-06 15:58:05 -08:00

55 lines
1.8 KiB
C#

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Linq;
using FluentAssertions;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Xunit;
using Xunit.Abstractions;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tests.ParserTests
{
public class UninstallInstallToolParserTests
{
private readonly ITestOutputHelper output;
public UninstallInstallToolParserTests(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void UninstallGlobaltoolParserCanGetPackageId()
{
var command = Parser.Instance;
var result = command.Parse("dotnet uninstall tool -g console.test.app");
var parseResult = result["dotnet"]["uninstall"]["tool"];
var packageId = parseResult.Arguments.Single();
packageId.Should().Be("console.test.app");
}
[Fact]
public void UninstallToolParserCanGetGlobalOption()
{
var result = Parser.Instance.Parse("dotnet uninstall tool -g console.test.app");
var appliedOptions = result["dotnet"]["uninstall"]["tool"];
appliedOptions.ValueOrDefault<bool>("global").Should().Be(true);
}
[Fact]
public void UninstallToolParserCanParseToolPathOption()
{
var result =
Parser.Instance.Parse(@"dotnet uninstall tool --tool-path C:\TestAssetLocalNugetFeed console.test.app");
var appliedOptions = result["dotnet"]["uninstall"]["tool"];
appliedOptions.SingleArgumentOrDefault("tool-path").Should().Be(@"C:\TestAssetLocalNugetFeed");
}
}
}