added unit test. made if condition easier to understand.

This commit is contained in:
discostu105 2016-02-23 15:53:51 +01:00
parent f0c8428925
commit d0d3a629a5
4 changed files with 83 additions and 3 deletions

View file

@ -7,6 +7,7 @@ using FluentAssertions;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.Extensions.PlatformAbstractions;
using NuGet.Frameworks;
using Xunit;
namespace Microsoft.DotNet.Tools.Builder.Tests
@ -128,6 +129,35 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
informationalVersion.Should().BeEquivalentTo("1.0.0-85");
}
[Theory]
[InlineData("net20", false)]
[InlineData("net40", true)]
[InlineData("net461", true)]
[InlineData("dnxcore50", true)]
public void MultipleFrameworks_ShouldHaveValidTargetFrameworkAttribute(string frameworkName, bool shouldHaveTargetFrameworkAttribute)
{
var framework = NuGetFramework.Parse(frameworkName);
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithMultipleFrameworks")
.WithLockFiles();
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");
var targetFramework = PeReaderUtils.GetAssemblyAttributeValue(output, "TargetFrameworkAttribute");
if (shouldHaveTargetFrameworkAttribute)
{
targetFramework.Should().NotBeNull();
targetFramework.Should().BeEquivalentTo(framework.DotNetFrameworkName);
}
else
{
targetFramework.Should().BeNull();
}
}
[Fact]
public void ResourceTest()
{