dotnet-installer/test/dotnet-msbuild.Tests/GivenDotnetStoreInvocation.cs

58 lines
2.5 KiB
C#
Raw Normal View History

// 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.
2017-02-22 18:43:05 +00:00
using FluentAssertions;
2017-04-10 19:24:52 +00:00
using Microsoft.DotNet.Tools.Store;
using System.IO;
2017-04-10 19:24:52 +00:00
using System.Linq;
using Xunit;
2017-02-22 18:43:05 +00:00
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
2017-04-07 19:15:38 +00:00
public class GivenDotnetStoreInvocation
2017-02-22 18:43:05 +00:00
{
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -target:ComposeStore <project>";
static readonly string[] ArgsPrefix = { "--manifest", "<project>" };
[Theory]
2017-04-07 19:15:38 +00:00
[InlineData("-m")]
[InlineData("--manifest")]
public void ItAddsProjectToMsbuildInvocation(string optionName)
{
var msbuildPath = "<msbuildpath>";
string[] args = new string[] { optionName, "<project>" };
2017-04-07 19:15:38 +00:00
StoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}");
}
[Theory]
[InlineData(new string[] { "-f", "<tfm>" }, @"-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, @"-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "-r", "<rid>" }, @"-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, @"-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"-property:AdditionalProjects=one.xml%3Btwo.xml%3Bthree.xml")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
2017-02-22 18:43:05 +00:00
{
args = ArgsPrefix.Concat(args).ToArray();
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
var msbuildPath = "<msbuildpath>";
2017-04-07 19:15:38 +00:00
StoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
}
[Theory]
[InlineData("-o")]
[InlineData("--output")]
public void ItAddsOutputPathToMsBuildInvocation(string optionName)
{
2017-03-17 06:15:45 +00:00
string path = "/some/path";
var args = ArgsPrefix.Concat(new string[] { optionName, path }).ToArray();
2017-02-22 18:43:05 +00:00
var msbuildPath = "<msbuildpath>";
2017-04-07 19:15:38 +00:00
StoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix} -property:ComposeDir={Path.GetFullPath(path)}");
2017-02-22 18:43:05 +00:00
}
}
}