// 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 { private const string ExpectedPrefix = "exec -maxcpucount -verbosity:m -nologo -target:Restore"; [Theory] [InlineData(new string[] { }, "")] [InlineData(new string[] { "-s", "" }, "-property:RestoreSources=")] [InlineData(new string[] { "--source", "" }, "-property:RestoreSources=")] [InlineData(new string[] { "-s", "", "-s", "" }, "-property:RestoreSources=%3B")] [InlineData(new string[] { "-r", "" }, "-property:RuntimeIdentifiers=")] [InlineData(new string[] { "--runtime", "" }, "-property:RuntimeIdentifiers=")] [InlineData(new string[] { "-r", "", "-r", "" }, "-property:RuntimeIdentifiers=%3B")] [InlineData(new string[] { "--packages", "" }, "-property:RestorePackagesPath=")] [InlineData(new string[] { "--disable-parallel" }, "-property:RestoreDisableParallel=true")] [InlineData(new string[] { "--configfile", "" }, "-property:RestoreConfigFile=")] [InlineData(new string[] { "--no-cache" }, "-property:RestoreNoCache=true")] [InlineData(new string[] { "--ignore-failed-sources" }, "-property:RestoreIgnoreFailedSources=true")] [InlineData(new string[] { "--no-dependencies" }, "-property: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}"); } } }