From a3126d6c9b88e2a6cddd354dd06ba655ed1ec485 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Wed, 22 Feb 2017 08:16:53 -0500 Subject: [PATCH] Add tests per tfm --- .../GivenThatWeWantToBuildALibraryWithTfm.cs | 591 ++++++++++++++++++ 1 file changed, 591 insertions(+) create mode 100644 test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithTfm.cs diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithTfm.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithTfm.cs new file mode 100644 index 000000000000..056eb2ddb490 --- /dev/null +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithTfm.cs @@ -0,0 +1,591 @@ +// 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 System.IO; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Assertions; +using Microsoft.NET.TestFramework.Commands; +using Xunit; +using static Microsoft.NET.TestFramework.Commands.MSBuildTest; +using System.Linq; +using FluentAssertions; +using System.Xml.Linq; +using System.Runtime.Versioning; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.NET.Build.Tests +{ + public class GivenThatWeWantToBuildALibraryWithTfm : SdkTest + { + [Fact] + public void It_builds_the_monoandroid_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "monoandroid"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb" + }); + } + + [Fact] + public void It_builds_the_net40_client_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "net40-client"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_net45_library_successfully() + { + const string tfm = "net45"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_netstandard15_library_successfully() + { + const string tfm = "netstandard1.5"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.deps.json" + }); + } + + [Fact] + public void It_builds_the_portable_profile44_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "portable-Profile44"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory("portable-win81+wpa81"); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.pri", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_portable_profile151_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "portable-Profile151"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory("portable-net451+wpa81+win81"); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_portable_profile259_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "portable-Profile259"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory("portable-net45+win8+wp8+wpa81"); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_sl5_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "sl5"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_win8_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "win8"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.pri", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_win81_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "win81"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.pri", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_wp8_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "wp8"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_wp81_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "wp81"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_wpa81_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "wpa81"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.pri", + $"{tfm}/Newtonsoft.Json.dll" + }); + } + + [Fact] + public void It_builds_the_uap10_0_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "uap10.0"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.pri" + }); + } + + [Fact] + public void It_builds_the_xamarinios_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "xamarinios"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.dll.mdb" + }); + } + + [Fact] + public void It_builds_the_xamarinmac_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "xamarinmac"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb" + }); + } + + [Fact] + public void It_builds_the_xamarintvos_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "xamarintvos"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.dll.mdb" + }); + } + + [Fact] + public void It_builds_the_xamarinwatchos_library_successfully_on_windows() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + const string tfm = "xamarinwatchos"; + + var testAsset = _testAssetsManager + .CopyTestAsset("LibraryWithTfm") + .WithSource() + .Restore(tfm); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, tfm); + + var buildCommand = new BuildCommand(Stage0MSBuild, libraryProjectDirectory); + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(tfm); + + outputDirectory.Should().OnlyHaveFiles(new[] { + $"{tfm}/{tfm}.dll", + $"{tfm}/{tfm}.pdb", + $"{tfm}/{tfm}.dll.mdb" + }); + } + } +} \ No newline at end of file