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

43 lines
2.1 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.
using Microsoft.DotNet.Tools.Clean;
2017-02-22 18:43:05 +00:00
using FluentAssertions;
using Xunit;
using System;
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetCleanInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -verbosity:normal -target:Clean";
2017-02-23 01:40:02 +00:00
[Fact]
public void ItAddsProjectToMsbuildInvocation()
{
var msbuildPath = "<msbuildpath>";
CleanCommand.FromArgs(new string[] { "<project>" }, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be("exec <msbuildpath> -maxcpucount -verbosity:m -verbosity:normal <project> -target:Clean");
2017-02-23 01:40:02 +00:00
}
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-o", "<output>" }, "-property:OutputPath=<output>")]
[InlineData(new string[] { "--output", "<output>" }, "-property:OutputPath=<output>")]
[InlineData(new string[] { "-f", "<framework>" }, "-property:TargetFramework=<framework>")]
[InlineData(new string[] { "--framework", "<framework>" }, "-property:TargetFramework=<framework>")]
[InlineData(new string[] { "-c", "<configuration>" }, "-property:Configuration=<configuration>")]
[InlineData(new string[] { "--configuration", "<configuration>" }, "-property:Configuration=<configuration>")]
[InlineData(new string[] { "-v", "diag" }, "-verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "-verbosity:diag")]
2017-02-23 01:40:02 +00:00
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
2017-02-22 18:43:05 +00:00
{
2017-02-23 01:40:02 +00:00
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
2017-02-22 18:43:05 +00:00
var msbuildPath = "<msbuildpath>";
2017-02-23 01:40:02 +00:00
CleanCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix}{expectedAdditionalArgs}");
2017-02-22 18:43:05 +00:00
}
}
}