Expand nodes for findNodes instead of refreshing (#599)

This commit is contained in:
Matt Irvine
2018-04-06 09:18:37 -07:00
committed by Karl Burtram
parent 2d4918ad83
commit 92456d50aa
3 changed files with 21 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
using Moq.Protected;
using Xunit;
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlServer.Management.Common;
@@ -263,6 +264,21 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
Assert.Equal(0, foundNodes.Count);
}
[Fact]
public void FindNodeCanExpandParentNodes()
{
var mockTreeNode = new Mock<TreeNode>();
object[] populateChildrenArguments = { ItExpr.Is<bool>(x => x == false), ItExpr.IsNull<string>() };
mockTreeNode.Protected().Setup("PopulateChildren", populateChildrenArguments);
mockTreeNode.Object.IsAlwaysLeaf = false;
// If I try to find a child node of the mock tree node with the expand parameter set to true
ObjectExplorerUtils.FindNode(mockTreeNode.Object, node => false, node => false, true);
// Then PopulateChildren gets called to expand the tree node
mockTreeNode.Protected().Verify("PopulateChildren", Times.Once(), populateChildrenArguments);
}
private async Task<SessionCreatedParameters> CreateSession()
{
SessionCreatedParameters sessionResult = null;