-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
GivenAResolveRuntimePackAssetsTask.cs
56 lines (49 loc) · 2.26 KB
/
GivenAResolveRuntimePackAssetsTask.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using FluentAssertions;
using Microsoft.Build.Utilities;
using Microsoft.NET.TestFramework;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.NET.Build.Tasks.UnitTests
{
public class GivenAResolveRuntimePackAssetsTask : SdkTest
{
public GivenAResolveRuntimePackAssetsTask(ITestOutputHelper log) : base(log)
{
}
[Fact]
public void ItFiltersSatelliteResources()
{
var testDirectory = _testAssetsManager.CreateTestDirectory().Path;
var task = new ResolveRuntimePackAssets()
{
BuildEngine = new MockBuildEngine(),
FrameworkReferences = new TaskItem[] { new TaskItem("TestFramework") },
ResolvedRuntimePacks = new TaskItem[]
{
new TaskItem("TestRuntimePack",
new Dictionary<string, string> {
{ "FrameworkName", "TestFramework" },
{ "RuntimeIdentifier", "test-rid" },
{ "PackageDirectory", testDirectory },
{ "PackageVersion", "0.1.0" },
{ "IsTrimmable", "false" }
})
},
SatelliteResourceLanguages = new TaskItem[] { new TaskItem("de") }
};
Directory.CreateDirectory(Path.Combine(testDirectory, "data"));
File.WriteAllText(
Path.Combine(testDirectory, "data", "RuntimeList.xml"),
@"<FileList Name="".NET Core 3.1"" TargetFrameworkIdentifier="".NETCoreApp"" TargetFrameworkVersion=""3.1"" FrameworkName=""Microsoft.NETCore.App"">
<File Type=""Resources"" Path=""runtimes/de/a.resources.dll"" Culture=""de"" FileVersion=""0.0.0.0"" />
<File Type=""Resources"" Path=""runtimes/cs/a.resources.dll"" Culture=""cs"" FileVersion=""0.0.0.0"" />
</FileList>");
task.Execute();
task.RuntimePackAssets.Should().HaveCount(1);
string expectedResource = Path.Combine("runtimes", "de", "a.resources.dll");
task.RuntimePackAssets.FirstOrDefault().ItemSpec.Should().Contain(expectedResource);
}
}
}