2017-03-02 21:04:03 -08: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 Microsoft.DotNet.Tools.Restore ;
2017-02-22 10:43:05 -08:00
using FluentAssertions ;
using Xunit ;
using System ;
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetRestoreInvocation
{
2017-05-18 14:13:01 -07:00
private const string ExpectedPrefix =
2017-10-24 15:50:43 -07:00
"exec <msbuildpath> /m /v:m /nologo /t:Restore" ;
2017-05-18 14:13:01 -07:00
2017-02-22 10:43:05 -08:00
[Theory]
2017-02-22 11:43:03 -08:00
[InlineData(new string[] { } , "" ) ]
[InlineData(new string[] { "-s" , "<source>" } , "/p:RestoreSources=<source>" ) ]
[InlineData(new string[] { "--source" , "<source>" } , "/p:RestoreSources=<source>" ) ]
[InlineData(new string[] { "-s" , "<source0>" , "-s" , "<source1>" } , "/p:RestoreSources=<source0>%3B<source1>" ) ]
[InlineData(new string[] { "-r" , "<runtime>" } , "/p:RuntimeIdentifiers=<runtime>" ) ]
[InlineData(new string[] { "--runtime" , "<runtime>" } , "/p:RuntimeIdentifiers=<runtime>" ) ]
[InlineData(new string[] { "-r" , "<runtime0>" , "-r" , "<runtime1>" } , "/p:RuntimeIdentifiers=<runtime0>%3B<runtime1>" ) ]
[InlineData(new string[] { "--packages" , "<packages>" } , "/p:RestorePackagesPath=<packages>" ) ]
[InlineData(new string[] { "--disable-parallel" } , "/p:RestoreDisableParallel=true" ) ]
[InlineData(new string[] { "--configfile" , "<config>" } , "/p:RestoreConfigFile=<config>" ) ]
[InlineData(new string[] { "--no-cache" } , "/p:RestoreNoCache=true" ) ]
[InlineData(new string[] { "--ignore-failed-sources" } , "/p:RestoreIgnoreFailedSources=true" ) ]
[InlineData(new string[] { "--no-dependencies" } , "/p:RestoreRecursive=false" ) ]
2017-03-09 09:14:55 -08:00
[InlineData(new string[] { "-v" , "minimal" } , @"/verbosity:minimal" ) ]
[InlineData(new string[] { "--verbosity" , "minimal" } , @"/verbosity:minimal" ) ]
2017-10-24 15:04:24 -07:00
public void MsbuildInvocationIsCorrect ( string [ ] args , string expectedAdditionalArgs )
2017-02-22 10:43:05 -08:00
{
2017-02-22 11:43:03 -08:00
expectedAdditionalArgs = ( string . IsNullOrEmpty ( expectedAdditionalArgs ) ? "" : $" {expectedAdditionalArgs}" ) ;
2017-02-22 10:43:05 -08:00
var msbuildPath = "<msbuildpath>" ;
2017-02-22 11:43:03 -08:00
RestoreCommand . FromArgs ( args , msbuildPath )
2017-05-18 14:13:01 -07:00
. GetProcessStartInfo ( ) . Arguments
. Should ( ) . Be ( $"{ExpectedPrefix}{expectedAdditionalArgs}" ) ;
2017-02-22 10:43:05 -08:00
}
}
}