提交 aa83bfbb 编写于 作者: S Sam Harwell

Move test helper to TestAccessor

上级 e19286c5
......@@ -241,21 +241,6 @@ private void ComputeTransitiveReferences(ProjectId project, HashSet<ProjectId> r
}
}
/// <summary>
/// Gets the list of projects that directly or transitively depend on this project, if it has already been
/// cached.
/// </summary>
internal ImmutableHashSet<ProjectId>? TryGetProjectsThatTransitivelyDependOnThisProject(ProjectId projectId)
{
if (projectId is null)
{
throw new ArgumentNullException(nameof(projectId));
}
_reverseTransitiveReferencesMap.TryGetValue(projectId, out var projects);
return projects;
}
/// <summary>
/// Gets the list of projects that directly or transitively depend on this project.
/// </summary>
......@@ -427,5 +412,33 @@ private void ComputedDependencySet(ProjectId project, HashSet<ProjectId> result)
}
}
}
internal TestAccessor GetTestAccessor()
=> new TestAccessor(this);
internal readonly struct TestAccessor
{
private readonly ProjectDependencyGraph _instance;
public TestAccessor(ProjectDependencyGraph instance)
{
_instance = instance;
}
/// <summary>
/// Gets the list of projects that directly or transitively depend on this project, if it has already been
/// cached.
/// </summary>
public ImmutableHashSet<ProjectId>? TryGetProjectsThatTransitivelyDependOnThisProject(ProjectId projectId)
{
if (projectId is null)
{
throw new ArgumentNullException(nameof(projectId));
}
_instance._reverseTransitiveReferencesMap.TryGetValue(projectId, out var projects);
return projects;
}
}
}
}
......@@ -513,7 +513,7 @@ public void TestReverseTransitiveReferencesAfterProjectReferenceRemoval_Preserve
// Before any other operations, verify that TryGetProjectsThatTransitivelyDependOnThisProject returns a
// non-null set. Specifically, it returns the _same_ set that was computed prior to the project reference
// removal.
Assert.Same(expected, solution.State.GetProjectDependencyGraph().TryGetProjectsThatTransitivelyDependOnThisProject(d.Id));
Assert.Same(expected, solution.State.GetProjectDependencyGraph().GetTestAccessor().TryGetProjectsThatTransitivelyDependOnThisProject(d.Id));
}
[Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
......@@ -541,7 +541,7 @@ public void TestReverseTransitiveReferencesAfterProjectReferenceRemoval_Preserve
// Before any other operations, verify that TryGetProjectsThatTransitivelyDependOnThisProject returns a
// non-null set. Specifically, it returns the _same_ set that was computed prior to the project reference
// removal.
Assert.Same(expected, solution.State.GetProjectDependencyGraph().TryGetProjectsThatTransitivelyDependOnThisProject(e.Id));
Assert.Same(expected, solution.State.GetProjectDependencyGraph().GetTestAccessor().TryGetProjectsThatTransitivelyDependOnThisProject(e.Id));
}
[Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
......@@ -569,7 +569,7 @@ public void TestReverseTransitiveReferencesAfterProjectReferenceRemoval_DiscardI
// Before any other operations, verify that TryGetProjectsThatTransitivelyDependOnThisProject returns a
// null set.
Assert.Null(solution.State.GetProjectDependencyGraph().TryGetProjectsThatTransitivelyDependOnThisProject(c.Id));
Assert.Null(solution.State.GetProjectDependencyGraph().GetTestAccessor().TryGetProjectsThatTransitivelyDependOnThisProject(c.Id));
VerifyReverseTransitiveReferences(solution, "C", new string[] { "B" });
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册