2017-03-03 05:04:03 +00: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.Clean;
|
2017-02-22 18:43:05 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.MSBuild.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotnetCleanInvocation
|
|
|
|
|
{
|
2018-04-02 22:14:32 +00:00
|
|
|
|
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)
|
2018-04-02 22:14:32 +00:00
|
|
|
|
.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[] { }, "")]
|
2018-04-26 17:53:54 +00:00
|
|
|
|
[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>\""")]
|
2018-04-02 21:44:43 +00:00
|
|
|
|
[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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|