dotnet restore using new parser

This commit is contained in:
Jon Sequeira 2017-03-06 20:53:26 -08:00
parent 0094fd4e08
commit 69bc90dc6f
5 changed files with 164 additions and 164 deletions

View file

@ -0,0 +1,47 @@
// 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 FluentAssertions;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Xunit;
using static Microsoft.DotNet.Cli.CommandLine.Accept;
using static Microsoft.DotNet.Cli.CommandLine.Create;
namespace Microsoft.DotNet.Tests.ParserTests
{
public class ArgumentForwardingExtensionsTests
{
[Fact]
public void An_outgoing_command_line_can_be_generated_based_on_a_parse_result()
{
var command = Command("the-command", "",
Option("-o|--one", "",
ZeroOrOneArgument.ForwardAs("/i:{0}")),
Option("-t|--two", "",
ZeroOrOneArgument.ForwardAs("/s:{0}")));
var result = command.Parse("the-command -t argument-two-value -o 123");
result["the-command"]
.ArgsToBeForwarded()
.Should()
.BeEquivalentTo("/i:123", "/s:argument-two-value");
}
[Fact]
public void MultipleArgumentsCanBeJoinedWhenForwarding()
{
var command = Command("the-command", "",
Option("-x", "",
ZeroOrMoreArguments.ForwardAs(o => $"/x:{string.Join("&", o.Arguments)}")));
var result = command.Parse("the-command -x one -x two");
result["the-command"]
.ArgsToBeForwarded()
.Should()
.BeEquivalentTo("/x:one&two");
}
}
}