-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
GivenAProjectContext.cs
44 lines (38 loc) · 1.62 KB
/
GivenAProjectContext.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
// 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 NuGet.Frameworks;
using NuGet.ProjectModel;
using Xunit;
namespace Microsoft.NET.Build.Tasks.UnitTests
{
public class GivenAProjectContext
{
[Fact]
public void ItComputesExcludeFromPublishList()
{
LockFile lockFile = TestLockFiles.GetLockFile("dependencies.withgraphs");
ProjectContext projectContext = lockFile.CreateProjectContext(
FrameworkConstants.CommonFrameworks.NetStandard16.GetShortFolderName(),
runtime: null,
Constants.DefaultPlatformLibrary,
runtimeFrameworks: null,
isSelfContained: false);
IEnumerable<string> excludeFromPublishPackageIds = new[] { "Microsoft.Extensions.Logging.Abstractions" };
IDictionary<string, LockFileTargetLibrary> libraryLookup =
projectContext
.LockFileTarget
.Libraries
.ToDictionary(e => e.Name, StringComparer.OrdinalIgnoreCase);
HashSet<string> exclusionList =
projectContext.GetExcludeFromPublishList(excludeFromPublishPackageIds, libraryLookup);
HashSet<string> expectedExclusions = new()
{
"Microsoft.Extensions.Logging.Abstractions",
"System.Collections.Concurrent",
"System.Diagnostics.Tracing",
};
exclusionList.Should().BeEquivalentTo(expectedExclusions);
}
}
}