Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projects only option tests #27

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Common/Common.Test/Common.Test/PackageDependencyGraphTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,30 @@ public async Task FromAssetsFile_WithProjectReferenceWithAPackageId_ParsesGraphC
ValidateBidirectionalEdges(nephewNode.Item1, nugetVersioning, VersionRange.Parse("6.3.0"));
}

[Fact]
public async Task FromAssetsFile_WithProjectsOnlyOption_IncludesProjectsOnly()
{
var assetsFileText = TestHelpers.GetResource("Common.Test.compiler.resources.nuget.common.assets.json", GetType());

var assetsFile = new LockFileFormat().Parse(assetsFileText, Path.GetTempPath());
var dependencyGraphSpec = new DependencyGraphSpec();
dependencyGraphSpec.AddProject(assetsFile.PackageSpec);
var graphs = await PackageDependencyGraph.GenerateAllDependencyGraphsFromAssetsFileAsync(assetsFile, dependencyGraphSpec, projectsOnly: true, new(), CancellationToken.None);
graphs.Should().HaveCount(2);

var graph = graphs.First().Value;
graph.Node.Identity.Id.Should().Be("NuGet.Common");
graph.Node.ParentNodes.Should().HaveCount(0);
graph.Node.ChildNodes.Should().HaveCount(1);

// Ensure NuGet.Common => NuGet.Frameworks
(Node<DependencyNodeIdentity, VersionRange>, VersionRange) nugetFrameworks = graph.Node.ChildNodes[0];
nugetFrameworks.Item1.Identity.Should().Be(new DependencyNodeIdentity("NuGet.Frameworks", new NuGetVersion(6, 4, 0, "preview.3.32767"), DependencyType.Project));
nugetFrameworks.Item1.ParentNodes.Should().HaveCount(1);
nugetFrameworks.Item1.ChildNodes.Should().HaveCount(0);
ValidateBidirectionalEdges(graph.Node, nugetFrameworks, VersionRange.Parse("6.4.0-preview.3.32767"));
}

private async Task<PackageDependencyGraph> GetOnlyDependencyGraphAsync(string resourceName)
{
var assetsFileText = TestHelpers.GetResource(resourceName, GetType());
Expand Down
Loading