Adding pack files migration.
This commit is contained in:
parent
ecbc45098d
commit
ddef1fc424
3 changed files with 112 additions and 17 deletions
|
@ -187,21 +187,53 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Migrating_Files_throws_an_exception_for_now()
|
||||
public void Migrating_Files_without_mappings_populates_content_with_same_path_as_include_and_pack_true()
|
||||
{
|
||||
Action action = () => RunPackOptionsRuleOnPj(@"
|
||||
var mockProj = RunPackOptionsRuleOnPj(@"
|
||||
{
|
||||
""packOptions"": {
|
||||
""files"": {
|
||||
""include"": [""somefile.cs""]
|
||||
""include"": [""path/to/some/file.cs"", ""path/to/some/other/file.cs""]
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
||||
action.ShouldThrow<Exception>()
|
||||
.Where(e => e.Message.Contains("Migrating projects with Files specified in PackOptions is not supported."));
|
||||
var contentItems = mockProj.Items
|
||||
.Where(item => item.ItemType.Equals("Content", StringComparison.Ordinal))
|
||||
.Where(item => item.GetMetadataWithName("Pack").Value == "True");
|
||||
|
||||
contentItems.Count().Should().Be(1);
|
||||
contentItems.First().Include.Should().Be(@"path\to\some\file.cs;path\to\some\other\file.cs");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Migrating_Files_with_mappings_populates_content_PackagePath_metadata()
|
||||
{
|
||||
var mockProj = RunPackOptionsRuleOnPj(@"
|
||||
{
|
||||
""packOptions"": {
|
||||
""files"": {
|
||||
""include"": [""path/to/some/file.cs""],
|
||||
""mappings"": {
|
||||
""some/other/path/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().Be(@"some/other/path");
|
||||
}
|
||||
|
||||
// add a test where we map the file to the empty folder (package root)
|
||||
|
||||
private ProjectRootElement RunPackOptionsRuleOnPj(string packOptions, string testDirectory = null)
|
||||
{
|
||||
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue