adding metadata to object explorer node info (#320)

* adding metadata to oe node info
This commit is contained in:
Leila Lali
2017-04-19 08:32:39 -07:00
committed by GitHub
parent 96d46b5c09
commit 8c0885da88
16 changed files with 121 additions and 81 deletions

View File

@@ -50,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.NotNull(session.Root);
NodeInfo nodeInfo = session.Root.ToNodeInfo();
Assert.Equal(nodeInfo.IsLeaf, false);
Assert.Equal(nodeInfo.NodeType, NodeTypes.ServerInstance.ToString());
Assert.Equal(nodeInfo.NodeType, NodeTypes.Server.ToString());
var children = session.Root.Expand();
//All server children should be folder nodes
@@ -61,7 +61,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases);
var databasesChildren = await _service.ExpandNode(session, databasesRoot.GetNodePath());
var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.DatabaseInstance.ToString());
var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.Database.ToString());
//Verify the test databases is in the list
Assert.NotNull(databases);
@@ -85,15 +85,29 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{
var children = await _service.ExpandNode(session, node.NodePath);
Assert.NotNull(children);
if(children.Count() == 0 && !node.NodePath.Contains("System") &&
if(!node.NodePath.Contains("System") &&
!node.NodePath.Contains("FileTables") && !node.NodePath.Contains("External Tables"))
{
var labaleToUpper = node.Label.ToUpper();
if (labaleToUpper.Contains("TABLE") || labaleToUpper.Contains("StoredProcedure")
|| labaleToUpper.Contains("VIEW"))
{
//TOOD: Add a better validation. For now at least check tables not to be empty
//Assert.True(false, "The list of tables, procedure and views cannot be empty");
foreach (var child in children)
{
if (child.NodeType != "Folder")
{
Assert.NotNull(child.Metadata);
if (!string.IsNullOrEmpty(child.Metadata.Schema))
{
Assert.Equal($"{child.Metadata.Schema}.{child.Metadata.Name}", child.Label);
}
else
{
Assert.Equal(child.Metadata.Name, child.Label);
}
}
}
}
}
foreach (var child in children)

View File

@@ -75,7 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
+ defaultConnectionDetails.UserName + ")";
Assert.Equal(expectedLabel, node.Label);
Assert.Equal(NodeTypes.ServerInstance.ToString(), node.NodeType);
Assert.Equal(NodeTypes.Server.ToString(), node.NodeType);
string[] nodePath = node.GetNodePath().Split(TreeNode.PathPartSeperator);
Assert.Equal(1, nodePath.Length);
Assert.Equal(defaultConnectionDetails.ServerName, nodePath[0]);

View File

@@ -103,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private void VerifyServerNode(NodeInfo serverNode, ConnectionDetails details)
{
Assert.NotNull(serverNode);
Assert.Equal(NodeTypes.ServerInstance.ToString(), serverNode.NodeType);
Assert.Equal(NodeTypes.Server.ToString(), serverNode.NodeType);
string[] pathParts = serverNode.NodePath.Split(TreeNode.PathPartSeperator);
Assert.Equal(1, pathParts.Length);
Assert.Equal(details.ServerName, pathParts[0]);

View File

@@ -193,7 +193,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
var schemaHierarchySearchPropertyLists = SR.SchemaHierarchy_SearchPropertyLists;
var schemaHierarchyColumnStoreIndexes = SR.SchemaHierarchy_ColumnStoreIndexes;
var schemaHierarchyTableTypeIndexes = SR.SchemaHierarchy_TableTypeIndexes;
var schemaHierarchyServerInstance = SR.SchemaHierarchy_ServerInstance;
var schemaHierarchyServerInstance = SR.SchemaHierarchy_Server;
var schemaHierarchySelectiveXmlIndexes = SR.SchemaHierarchy_SelectiveXmlIndexes;
var schemaHierarchyXmlNamespaces = SR.SchemaHierarchy_XmlNamespaces;
var schemaHierarchyXmlTypedPromotedPaths = SR.SchemaHierarchy_XmlTypedPromotedPaths;

View File

@@ -7,6 +7,8 @@ using System.Globalization;
using Xunit;
using ServiceLayerSr = Microsoft.SqlTools.ServiceLayer.Localization.sr;
using HostingSr = Microsoft.SqlTools.Hosting.Localization.sr;
using CredentialSr = Microsoft.SqlTools.Credentials.Localization.sr;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{
@@ -23,7 +25,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
Assert.NotNull(SR.QueryServiceFileWrapperNotInitialized);
Assert.NotNull(SR.QueryServiceColumnNull);
var sr = new ServiceLayerSr();
Assert.NotNull(ServiceLayerSr.ResourceManager);
ServiceLayerSr.Culture = CultureInfo.CurrentCulture;
Assert.NotNull(ServiceLayerSr.Culture);