From dc0d87c8261f464e42cb07502d2e7136430a996a Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Thu, 20 Oct 2016 11:56:30 -0700 Subject: [PATCH] Adding an additional test to validate mappings to the root of the package. --- .../GivenThatIWantToMigratePackOptions.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs index 3d5f76076..9f2066dee 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigratePackOptions.cs @@ -232,7 +232,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests contentItems.First().GetMetadataWithName("PackagePath").Value.Should().Be(@"some/other/path"); } - // add a test where we map the file to the empty folder (package root) + [Fact] + public void Migrating_Files_with_mappings_to_root_populates_content_PackagePath_metadata_but_leaves_it_empty() + { + var mockProj = RunPackOptionsRuleOnPj(@" + { + ""packOptions"": { + ""files"": { + ""include"": [""path/to/some/file.cs""], + ""mappings"": { + "".file.cs"": ""path/to/some/file.cs"" + } + } + } + }"); + + var contentItems = mockProj.Items + .Where(item => item.ItemType.Equals("Content", StringComparison.Ordinal)) + .Where(item => + item.GetMetadataWithName("Pack").Value == "True" && + item.GetMetadataWithName("PackagePath") != null); + + contentItems.Count().Should().Be(1); + contentItems.First().Include.Should().Be(@"path\to\some\file.cs"); + contentItems.First().GetMetadataWithName("PackagePath").Value.Should().BeEmpty(); + } private ProjectRootElement RunPackOptionsRuleOnPj(string packOptions, string testDirectory = null) {