2018-03-16 21:56:24 +00:00
|
|
|
// 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 ListToolParserTests
|
|
|
|
{
|
|
|
|
private readonly ITestOutputHelper output;
|
|
|
|
|
|
|
|
public ListToolParserTests(ITestOutputHelper output)
|
|
|
|
{
|
|
|
|
this.output = output;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ListToolParserCanGetGlobalOption()
|
|
|
|
{
|
2018-03-22 02:12:32 +00:00
|
|
|
var result = Parser.Instance.Parse("dotnet tool list -g");
|
2018-03-16 21:56:24 +00:00
|
|
|
|
2018-03-22 02:12:32 +00:00
|
|
|
var appliedOptions = result["dotnet"]["tool"]["list"];
|
2018-03-16 21:56:24 +00:00
|
|
|
appliedOptions.ValueOrDefault<bool>("global").Should().Be(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void ListToolParserCanParseToolPathOption()
|
|
|
|
{
|
|
|
|
var result =
|
2018-03-22 02:12:32 +00:00
|
|
|
Parser.Instance.Parse(@"dotnet tool list --tool-path C:\Tools ");
|
2018-03-16 21:56:24 +00:00
|
|
|
|
2018-03-22 02:12:32 +00:00
|
|
|
var appliedOptions = result["dotnet"]["tool"]["list"];
|
2018-03-16 21:56:24 +00:00
|
|
|
appliedOptions.SingleArgumentOrDefault("tool-path").Should().Be(@"C:\Tools");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|