// 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; using FluentAssertions; using Xunit; using System; namespace Microsoft.DotNet.Cli.MSBuild.Tests { public class GivenDotnetRestoreInvocation { const string ExpectedPrefix = "exec /m /v:m /NoLogo /t:Restore /ConsoleLoggerParameters:Verbosity=Minimal"; [Theory] [InlineData(new string[] { }, "")] [InlineData(new string[] { "-s", "" }, "/p:RestoreSources=")] [InlineData(new string[] { "--source", "" }, "/p:RestoreSources=")] [InlineData(new string[] { "-s", "", "-s", "" }, "/p:RestoreSources=%3B")] [InlineData(new string[] { "-r", "" }, "/p:RuntimeIdentifiers=")] [InlineData(new string[] { "--runtime", "" }, "/p:RuntimeIdentifiers=")] [InlineData(new string[] { "-r", "", "-r", "" }, "/p:RuntimeIdentifiers=%3B")] [InlineData(new string[] { "--packages", "" }, "/p:RestorePackagesPath=")] [InlineData(new string[] { "--disable-parallel" }, "/p:RestoreDisableParallel=true")] [InlineData(new string[] { "--configfile", "" }, "/p:RestoreConfigFile=")] [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")] [InlineData(new string[] { "-v", "minimal" }, @"/verbosity:minimal")] [InlineData(new string[] { "--verbosity", "minimal" }, @"/verbosity:minimal")] public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs) { expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}"); var msbuildPath = ""; RestoreCommand.FromArgs(args, msbuildPath) .GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}"); } } }