forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for setting Configuration in Directory.Build.props
- Loading branch information
1 parent
d747e69
commit ea991d7
Showing
2 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
test/Microsoft.NET.Build.Tests/GivenThatWeWantToSetPropertiesInDirectoryBuildProps.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using FluentAssertions; | ||
using Microsoft.NET.TestFramework; | ||
using Microsoft.NET.TestFramework.Assertions; | ||
using Microsoft.NET.TestFramework.ProjectConstruction; | ||
using Microsoft.NET.TestFramework.Commands; | ||
using static Microsoft.NET.TestFramework.Commands.MSBuildTest; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Xml.Linq; | ||
using Xunit; | ||
|
||
namespace Microsoft.NET.Build.Tests | ||
{ | ||
public class GivenThatWeWantToSetPropertiesInDirectoryBuildProps : SdkTest | ||
{ | ||
|
||
[Fact] | ||
public void The_default_configuration_can_be_set_to_release() | ||
{ | ||
TestProject project = new TestProject() | ||
{ | ||
Name = "DirectoryBuildPropsTest", | ||
TargetFrameworks = "netstandard1.4", | ||
IsSdkProject = true | ||
}; | ||
|
||
var testAsset = _testAssetsManager.CreateTestProject(project); | ||
|
||
string directoryBuildPropsPath = Path.Combine(testAsset.Path, "Directory.Build.props"); | ||
|
||
var directoryBuildPropsContent = @" | ||
<Project> | ||
<PropertyGroup> | ||
<Configuration Condition="" '$(Configuration)' == '' "">Release</Configuration> | ||
</PropertyGroup> | ||
</Project> | ||
"; | ||
|
||
File.WriteAllText(directoryBuildPropsPath, directoryBuildPropsContent); | ||
|
||
var restoreCommand = testAsset.GetRestoreCommand(project.Name); | ||
|
||
restoreCommand | ||
.Execute() | ||
.Should() | ||
.Pass(); | ||
|
||
string projectFolder = Path.Combine(testAsset.Path, project.Name); | ||
|
||
var buildCommand = new BuildCommand(Stage0MSBuild, projectFolder); | ||
|
||
buildCommand | ||
.Execute() | ||
.Should() | ||
.Pass(); | ||
|
||
string GetPropertyValue(string propertyName) | ||
{ | ||
var getValuesCommand = new GetValuesCommand(Stage0MSBuild, projectFolder, | ||
project.TargetFrameworks, propertyName, GetValuesCommand.ValueType.Property) | ||
{ | ||
Configuration = "Release" | ||
}; | ||
|
||
getValuesCommand | ||
.Execute() | ||
.Should() | ||
.Pass(); | ||
|
||
var values = getValuesCommand.GetValues(); | ||
values.Count.Should().Be(1); | ||
return values[0]; | ||
} | ||
|
||
GetPropertyValue("Configuration").Should().Be("Release"); | ||
GetPropertyValue("Optimize").Should().Be("true"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters