assert on Should().Fail() on non-windows platforms for desktop frameworks
This commit is contained in:
parent
5ad60df96a
commit
af5aaea6d0
1 changed files with 17 additions and 13 deletions
|
@ -137,30 +137,34 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
[InlineData("dnxcore50", true, false)]
|
[InlineData("dnxcore50", true, false)]
|
||||||
public void MultipleFrameworks_ShouldHaveValidTargetFrameworkAttribute(string frameworkName, bool shouldHaveTargetFrameworkAttribute, bool windowsOnly)
|
public void MultipleFrameworks_ShouldHaveValidTargetFrameworkAttribute(string frameworkName, bool shouldHaveTargetFrameworkAttribute, bool windowsOnly)
|
||||||
{
|
{
|
||||||
if (windowsOnly && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
|
||||||
return; // don't run test for desktop framework on non-windows
|
|
||||||
}
|
|
||||||
|
|
||||||
var framework = NuGetFramework.Parse(frameworkName);
|
var framework = NuGetFramework.Parse(frameworkName);
|
||||||
|
|
||||||
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithMultipleFrameworks")
|
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithMultipleFrameworks")
|
||||||
.WithLockFiles();
|
.WithLockFiles();
|
||||||
|
|
||||||
var cmd = new BuildCommand(Path.Combine(testInstance.TestRoot, Project.FileName), framework: framework.GetShortFolderName());
|
var cmd = new BuildCommand(Path.Combine(testInstance.TestRoot, Project.FileName), framework: framework.GetShortFolderName());
|
||||||
cmd.ExecuteWithCapturedOutput().Should().Pass();
|
|
||||||
|
|
||||||
var output = Path.Combine(testInstance.TestRoot, "bin", "Debug", framework.GetShortFolderName(), "TestLibraryWithMultipleFrameworks.dll");
|
if (windowsOnly && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
var targetFramework = PeReaderUtils.GetAssemblyAttributeValue(output, "TargetFrameworkAttribute");
|
|
||||||
|
|
||||||
if (shouldHaveTargetFrameworkAttribute)
|
|
||||||
{
|
{
|
||||||
targetFramework.Should().NotBeNull();
|
// on non-windows platforms, desktop frameworks will not build
|
||||||
targetFramework.Should().BeEquivalentTo(framework.DotNetFrameworkName);
|
cmd.ExecuteWithCapturedOutput().Should().Fail();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetFramework.Should().BeNull();
|
cmd.ExecuteWithCapturedOutput().Should().Pass();
|
||||||
|
|
||||||
|
var output = Path.Combine(testInstance.TestRoot, "bin", "Debug", framework.GetShortFolderName(), "TestLibraryWithMultipleFrameworks.dll");
|
||||||
|
var targetFramework = PeReaderUtils.GetAssemblyAttributeValue(output, "TargetFrameworkAttribute");
|
||||||
|
|
||||||
|
if (shouldHaveTargetFrameworkAttribute)
|
||||||
|
{
|
||||||
|
targetFramework.Should().NotBeNull();
|
||||||
|
targetFramework.Should().BeEquivalentTo(framework.DotNetFrameworkName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetFramework.Should().BeNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue