public async Task DependenciesGraphProvider_GetChildrenAsync() { var projectPath = @"c:\myproject\project.csproj"; var nodeIdString = @"file:///[MyProvider;MyNodeItemSpec]"; var nodeJson = @" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"; var childNodeJson = @" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"; var existingNode = IDependencyNodeFactory.FromJson(nodeJson); var existingChildNode = IDependencyNodeFactory.FromJson(childNodeJson); existingNode.Children.Add(existingChildNode); var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeIdString, existingNode); var outputNodes = new HashSet <GraphNode>(); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.AddTestDependencyNodes(new[] { existingNode }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement(projectPath, mockProvider); var mockGraphContext = IGraphContextFactory.ImplementGetChildrenAsync(inputNode, trackChanges: true, outputNodes: outputNodes); var provider = new TestableDependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.Equal(1, outputNodes.Count); var childGraphNode = outputNodes.First(); Assert.Equal(existingChildNode, childGraphNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.False(childGraphNode.GetValue <bool>(DgmlNodeProperties.ContainsChildren)); var childProjectPath = childGraphNode.Id.GetNestedValueByName <Uri>(CodeGraphNodeIdName.Assembly); Assert.Equal(projectPath.Replace('\\', '/'), childProjectPath.AbsolutePath); var childSubTreeProvider = childGraphNode.GetValue(DependenciesGraphSchema.ProviderProperty); Assert.True(childSubTreeProvider is IProjectDependenciesSubTreeProviderMock); Assert.Equal("MyDefaultTestProvider", ((IProjectDependenciesSubTreeProviderMock)childSubTreeProvider).ProviderTestType); Assert.Equal(1, childGraphNode.IncomingLinkCount); Assert.Equal(1, provider.GetRegisteredSubTreeProviders().Count()); }
public async Task DependenciesGraphProvider_CheckChildrenAsync_TopLevelNodeWithoutId_ShouldGetProviderFromParent() { var projectPath = @"c:\myproject\project.csproj"; var parentNodeIdString = @"file:///[MyProvider;;;]"; var nodeFilePath = @"c:/myproject/MyNodeItemSpec"; var mockVsHierarchyItem = IVsHierarchyItemFactory.ImplementProperties( text: "MyNodeItemSpec", parentCanonicalName: parentNodeIdString); var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeFilePath, hierarchyItem: mockVsHierarchyItem); var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var existingNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); var existingChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"); rootNode.AddChild(existingNode); existingNode.Children.Add(existingChildNode); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = rootNode; mockProvider.AddTestDependencyNodes(new[] { existingNode }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement(projectPath, mockProvider); var mockGraphContext = IGraphContextFactory.ImplementContainsChildren(inputNode); var provider = new DependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.True(inputNode.GetValue <bool>(DgmlNodeProperties.ContainsChildren)); Assert.NotNull(inputNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.Equal(existingNode, inputNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.True(inputNode.GetValue(DependenciesGraphSchema.ProviderProperty) is IProjectDependenciesSubTreeProviderMock); }
public async Task DependenciesGraphProvider_CheckChildrenAsync_HasChildrenFalse() { var projectPath = @"c:\myproject\project.csproj"; var nodeIdString = @"file:///[MyProvider;MyNodeItemSpec]"; var mockVsHierarchyItem = IVsHierarchyItemFactory.ImplementProperties(text: "MyNodeItemSpec"); var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeIdString, hierarchyItem: mockVsHierarchyItem); var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var existingNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); rootNode.AddChild(existingNode); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = rootNode; mockProvider.AddTestDependencyNodes(new[] { existingNode }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement(projectPath, mockProvider); var mockGraphContext = IGraphContextFactory.Implement(CancellationToken.None, new HashSet <GraphNode>() { inputNode }, GraphContextDirection.Self, new List <GraphProperty> { DgmlNodeProperties.ContainsChildren }); var provider = new DependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.False(inputNode.GetValue <bool>(DgmlNodeProperties.ContainsChildren)); Assert.NotNull(inputNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.Equal(existingNode, inputNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.True(inputNode.GetValue(DependenciesGraphSchema.ProviderProperty) is IProjectDependenciesSubTreeProviderMock); }
public async Task DependenciesGraphProvider_TrackChangesAsync_InvalidNodeData( string projectPath, bool existingNodeSpecified, bool updatedNodeProvided) { var nodeIdString = @"file:///[MyProvider;MyNodeItemSpec]"; var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeIdString); var existingNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); var existingChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpecExisting"" } }"); var existingRefreshedNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); var newChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpecNew"" } }"); existingNode.Children.Add(existingChildNode); existingRefreshedNode.AddChild(newChildNode); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); if (updatedNodeProvided) { mockProvider.AddTestDependencyNodes(new[] { existingRefreshedNode }); } if (existingNodeSpecified) { inputNode.SetValue(DependenciesGraphSchema.DependencyNodeProperty, existingNode); } inputNode.SetValue(DependenciesGraphSchema.ProviderProperty, mockProvider); var outputNodes = new HashSet <GraphNode>(); var mockGraphContext = IGraphContextFactory.ImplementTrackChanges(inputNode, outputNodes); var updatedProjectContext = IDependenciesGraphProjectContextProviderFactory.ImplementProjectContext(projectPath); var provider = new TestableDependenciesGraphProvider(IDependenciesGraphProjectContextProviderFactory.Create(), Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); provider.AddExpandedGraphContext(mockGraphContext); // Act await provider.TrackChangesAsync(updatedProjectContext); // Assert Assert.Equal(0, outputNodes.Count); }
public async Task DependenciesGraphProvider_TrackChangesAsync_WithContextProject() { var projectPath = @"c:\myproject\project.csproj"; var contextProjectPath = @"c:\mycontextproject\project.csproj"; var nodeIdString = @"file:///[MyProvider;MyNodeItemSpec]"; var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeIdString); var existingNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); existingNode.Id.ContextProject = contextProjectPath; var existingChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpecExisting"" } }"); var existingRefreshedNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); existingRefreshedNode.Id.ContextProject = contextProjectPath; var newChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpecNew"" } }"); existingNode.Children.Add(existingChildNode); existingRefreshedNode.AddChild(newChildNode); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.AddTestDependencyNodes(new[] { existingRefreshedNode }); inputNode.SetValue(DependenciesGraphSchema.DependencyNodeProperty, existingNode); inputNode.SetValue(DependenciesGraphSchema.ProviderProperty, mockProvider); var outputNodes = new HashSet <GraphNode>(); var mockGraphContext = IGraphContextFactory.ImplementTrackChanges(inputNode, outputNodes); var updatedProjectContext = IDependenciesGraphProjectContextProviderFactory.ImplementProjectContext(contextProjectPath); var provider = new TestableDependenciesGraphProvider(IDependenciesGraphProjectContextProviderFactory.Create(), Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); provider.AddExpandedGraphContext(mockGraphContext); // Act await provider.TrackChangesAsync(updatedProjectContext); // Assert Assert.Equal(1, outputNodes.Count); var outputNode = outputNodes.First(); var outputDependency = outputNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty); Assert.Equal(newChildNode.Id, outputDependency.Id); var childProjectPath = outputNode.Id.GetNestedValueByName <Uri>(CodeGraphNodeIdName.Assembly); Assert.Equal(contextProjectPath.Replace('\\', '/'), childProjectPath.AbsolutePath); }
public async Task DependenciesGraphProvider_SearchAsync_TopLevel_GenericNode_WithNormalItemSpec() { // Arrange var searchString = "1.0"; var projectPath = @"c:\myproject\project.csproj"; var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var topNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec"" } }", DependencyNode.GenericDependencyFlags); ((DependencyNode)topNode1).Name = "TopNodeName"; var childNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec1.0"" } }"); topNode1.Children.Add(childNode1); rootNode.AddChild(topNode1); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = rootNode; mockProvider.AddTestDependencyNodes(new[] { topNode1 }); mockProvider.AddSearchResults(new[] { topNode1 }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement( projectPath, subTreeProviders: new[] { mockProvider }); var outputNodes = new HashSet <GraphNode>(); var mockGraphContext = IGraphContextFactory.ImplementSearchAsync(searchString, outputNodes: outputNodes); var provider = new TestableDependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.Equal(2, outputNodes.Count); var outputArray = outputNodes.ToArray(); // check if top level nodes got CodeNodeCategories.ProjectItem to make sure // graph matched them back with IVsHierarchy nodes Assert.True(outputArray[0].HasCategory(CodeNodeCategories.ProjectItem)); Assert.Equal(1, outputArray[0].OutgoingLinkCount); Assert.Equal(@"c:/myproject/mytopnodeitemspec", outputArray[0].Id.GetNestedValueByName <Uri>(CodeGraphNodeIdName.File).AbsolutePath); Assert.False(outputArray[1].HasCategory(CodeNodeCategories.ProjectItem)); }
public async Task DependenciesGraphProvider_SearchAsync() { // Arrange var searchString = "1.0"; var projectPath = @"c:\myproject\project.csproj"; var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var topNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec"" } }"); var topNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec/1.0.0"" } }"); var topNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec3/1.0.0"" } }"); var childNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec1.0"" } }"); var childNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec/1.0.0"" } }"); var childNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"); topNode1.Children.Add(childNode1); topNode2.Children.Add(childNode3); topNode2.Children.Add(childNode2); rootNode.AddChild(topNode1); rootNode.AddChild(topNode2); rootNode.AddChild(topNode3); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = rootNode; mockProvider.AddTestDependencyNodes(new[] { topNode1, topNode2, topNode3 }); mockProvider.AddSearchResults(new[] { topNode1, topNode2, topNode3 }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement( projectPath, subTreeProviders: new[] { mockProvider }); var outputNodes = new HashSet <GraphNode>(); var mockGraphContext = IGraphContextFactory.ImplementSearchAsync(searchString, outputNodes: outputNodes); var provider = new TestableDependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.Equal(5, outputNodes.Count); var outputArray = outputNodes.ToArray(); // check if top level nodes got CodeNodeCategories.ProjectItem to make sure // graph matched them back with IVsHierarchy nodes Assert.True(outputArray[0].HasCategory(CodeNodeCategories.ProjectItem)); Assert.Equal(1, outputArray[0].OutgoingLinkCount); Assert.True(outputArray[2].HasCategory(CodeNodeCategories.ProjectItem)); Assert.Equal(2, outputArray[2].OutgoingLinkCount); Assert.False(outputArray[1].HasCategory(CodeNodeCategories.ProjectItem)); Assert.False(outputArray[3].HasCategory(CodeNodeCategories.ProjectItem)); Assert.False(outputArray[4].HasCategory(CodeNodeCategories.ProjectItem)); }
public async Task DependenciesGraphProvider_GetChildrenAsync_NoNodeAttachedToInputNode_ShouldDiscoverItAgain() { var projectPath = @"c:\myproject\project.csproj"; var nodeIdString = @"file:///[MyProvider;MyNodeItemSpec]"; var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var existingNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyNodeItemSpec"" } }"); var existingChildNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"); rootNode.AddChild(existingNode); existingNode.Children.Add(existingChildNode); var mockVsHierarchyItem = IVsHierarchyItemFactory.ImplementProperties(text: "MyNodeItemSpec"); var inputNode = IGraphContextFactory.CreateNode(projectPath, nodeIdString, hierarchyItem: mockVsHierarchyItem); var outputNodes = new HashSet <GraphNode>(); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = rootNode; mockProvider.AddTestDependencyNodes(new[] { existingNode }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement(projectPath, mockProvider); var mockGraphContext = IGraphContextFactory.ImplementGetChildrenAsync(inputNode, trackChanges: true, outputNodes: outputNodes); var provider = new TestableDependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.Equal(1, outputNodes.Count); var childGraphNode = outputNodes.First(); Assert.Equal(existingChildNode, childGraphNode.GetValue <IDependencyNode>(DependenciesGraphSchema.DependencyNodeProperty)); Assert.False(childGraphNode.GetValue <bool>(DgmlNodeProperties.ContainsChildren)); Assert.True(childGraphNode.GetValue(DependenciesGraphSchema.ProviderProperty) is IProjectDependenciesSubTreeProviderMock); Assert.Equal(1, childGraphNode.IncomingLinkCount); Assert.Equal(1, provider.GetRegisteredSubTreeProviders().Count()); }
public void ProjectDependenciesSubTreeProvider_GetDependencyNode() { // Arrange var projectPath = @"c:\myproject\project.csproj"; // our provider under test nodes var myRootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""ProviderUnderTest"", ""ItemSpec"": ""RootNodeUnderTest"" } }"); var myTopNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""ProviderUnderTest"", ""ItemSpec"": ""MyTopNodeItemSpec1"" } }"); var myDependencyNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""ProviderUnderTest"", ""ItemSpec"": ""MyDependencyNodeItemSpec1"" } }"); myDependencyNode1.Id.ContextProject = "c:\\myproject\\project.csproj"; myTopNode1.AddChild(myDependencyNode1); myRootNode.AddChild(myTopNode1); // other provider nodes var otherProviderRootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var topNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec"" } }"); var topNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec/1.0.0"" } }"); var topNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec3/1.0.0"" } }"); var childNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec1.0"" } }"); var childNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec/1.0.0"" } }"); var childNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"); topNode1.AddChild(childNode1); topNode2.AddChild(childNode3); topNode2.AddChild(childNode2); otherProviderRootNode.AddChild(topNode1); otherProviderRootNode.AddChild(topNode2); otherProviderRootNode.AddChild(topNode3); var mockProvider = new IProjectDependenciesSubTreeProviderMock(); mockProvider.RootNode = otherProviderRootNode; mockProvider.AddTestDependencyNodes(new[] { topNode1, topNode2, topNode3 }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement( projectPath, subTreeProviders: new[] { mockProvider }); var provider = new TestableProjectDependenciesSubTreeProvider(unconfiguredProject: null, projectContextProvider: mockProjectContextProvider); provider.SetRootNode(myRootNode); // Act var resultNode = provider.GetDependencyNode(myDependencyNode1.Id); // Assert Assert.Equal(resultNode.Id, myDependencyNode1.Id); Assert.Equal(3, resultNode.Children.Count); }
public async Task DependenciesGraphProvider_SearchAsync() { // Arrange var searchString = "1.0"; var projectPath = @"c:\myproject\project.csproj"; var rootNode = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyRootNode"" } }"); var topNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec"" } }"); var topNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec/1.0.0"" } }"); var topNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyTopNodeItemSpec3/1.0.0"" } }"); var childNode1 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec1.0"" } }"); var childNode2 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec/1.0.0"" } }"); var childNode3 = IDependencyNodeFactory.FromJson(@" { ""Id"": { ""ProviderType"": ""MyProvider"", ""ItemSpec"": ""MyChildNodeItemSpec"" } }"); topNode1.AddChild(childNode1); topNode2.AddChild(childNode3); topNode2.AddChild(childNode2); rootNode.AddChild(topNode1); rootNode.AddChild(topNode2); rootNode.AddChild(topNode3); var mockProvider = new IProjectDependenciesSubTreeProviderMock { RootNode = rootNode }; mockProvider.AddTestDependencyNodes(new[] { topNode1, topNode2, topNode3 }); mockProvider.AddSearchResults(new[] { topNode1, topNode2, topNode3 }); var mockProjectContextProvider = IDependenciesGraphProjectContextProviderFactory.Implement( projectPath, subTreeProviders: new[] { mockProvider }); var outputNodes = new HashSet <GraphNode>(); var mockGraphContext = IGraphContextFactory.ImplementSearchAsync(searchString, outputNodes: outputNodes); var provider = new TestableDependenciesGraphProvider(mockProjectContextProvider, Mock.Of <SVsServiceProvider>(), new IProjectThreadingServiceMock().JoinableTaskContext); // Act await provider.BeginGetGraphDataAsync(mockGraphContext); // Assert Assert.Equal(4, outputNodes.Count); var topNode1Result = GetNodeById(projectPath, outputNodes, topNode1.Id); Assert.True(topNode1Result.HasCategory(CodeNodeCategories.ProjectItem)); Assert.Equal(1, topNode1Result.OutgoingLinkCount); var topNode2Result = GetNodeById(projectPath, outputNodes, topNode2.Id); Assert.Equal(1, topNode2Result.OutgoingLinkCount); Assert.True(topNode2Result.HasCategory(CodeNodeCategories.ProjectItem)); var childNode1Result = GetNodeById(projectPath, outputNodes, childNode1.Id); Assert.Equal(0, childNode1Result.OutgoingLinkCount); Assert.False(childNode1Result.HasCategory(CodeNodeCategories.ProjectItem)); var childNode2Result = GetNodeById(projectPath, outputNodes, childNode2.Id); Assert.Equal(0, childNode2Result.OutgoingLinkCount); Assert.False(childNode2Result.HasCategory(CodeNodeCategories.ProjectItem)); }