From 8c0885da887181414a965fe809380b3972731204 Mon Sep 17 00:00:00 2001 From: Leila Lali Date: Wed, 19 Apr 2017 08:32:39 -0700 Subject: [PATCH] adding metadata to object explorer node info (#320) * adding metadata to oe node info --- .../Localization/sr.cs | 6 +- .../Localization/sr.resx | 4 +- .../Localization/sr.strings | 2 +- .../Localization/sr.xlf | 10 +-- .../ObjectExplorer/Contracts/NodeInfo.cs | 7 ++ .../ObjectExplorer/Nodes/NodeTypes.cs | 25 ++++--- .../ObjectExplorer/Nodes/TreeNode.cs | 11 +++- .../ObjectExplorer/SmoModel/ServerNode.cs | 4 +- .../ObjectExplorer/SmoModel/SmoTreeNode.cs | 12 ++++ .../SmoModel/TreeNodeDefinition.xml | 22 +++---- .../SmoModel/TreeNodeGenerator.cs | 66 +++++++++---------- .../ObjectExplorerServiceTests.cs | 24 +++++-- .../ObjectExplorer/NodeTests.cs | 2 +- .../ObjectExplorerServiceTests.cs | 2 +- .../ServiceHost/SrTests.cs | 2 +- .../Utility/SrTests.cs | 3 +- 16 files changed, 121 insertions(+), 81 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index c8ee4d091b..64342d99da 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -2053,11 +2053,11 @@ public static string SchemaHierarchy_TableTypeIndexes } } - public static string SchemaHierarchy_ServerInstance + public static string SchemaHierarchy_Server { get { - return Keys.GetString(Keys.SchemaHierarchy_ServerInstance); + return Keys.GetString(Keys.SchemaHierarchy_Server); } } @@ -3036,7 +3036,7 @@ public class Keys public const string SchemaHierarchy_TableTypeIndexes = "SchemaHierarchy_TableTypeIndexes"; - public const string SchemaHierarchy_ServerInstance = "SchemaHierarchy_ServerInstance"; + public const string SchemaHierarchy_Server = "SchemaHierarchy_Server"; public const string SchemaHierarchy_SelectiveXmlIndexes = "SchemaHierarchy_SelectiveXmlIndexes"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index 76ad3db37e..03e831de9f 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -1199,8 +1199,8 @@ Table Type Indexes - - ServerInstance + + Server diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index 0bb0b741d3..518320ed1f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -597,7 +597,7 @@ SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes SchemaHierarchy_TableTypeIndexes = Table Type Indexes -SchemaHierarchy_ServerInstance = ServerInstance +SchemaHierarchy_Server = Server SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index de85581cc6..0a67949318 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -1351,11 +1351,6 @@ Table Type Indexes - - ServerInstance - ServerInstance - - Selective XML Indexes Selective XML Indexes @@ -1416,6 +1411,11 @@ Column Encryption Keys + + Server + Server + + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs index b97f647dad..a0eb8f3286 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Contracts/NodeInfo.cs @@ -3,6 +3,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts; + namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts { /// @@ -36,5 +38,10 @@ public class NodeInfo /// is it expandable? /// public bool IsLeaf { get; set; } + + /// + /// Object Metadata for smo objects to be used for scripting + /// + public ObjectMetadata Metadata { get; set; } } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs index 2305cb7fab..cff3105cde 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs @@ -13,18 +13,17 @@ public enum NodeTypes { None, SqlServersRoot, - DatabaseInstance, - DacInstance, - ServerInstance, - ScalarValuedFunctionInstance, - TableValuedFunctionInstance, - AggregateFunctionInstance, + Database, + Server, + ScalarValuedFunction, + TableValuedFunction, + AggregateFunction, FileGroupInstance, - StoredProcedureInstance, - UserDefinedTableTypeInstance, - ViewInstance, - TableInstance, - HistoryTableInstance, + StoredProcedure, + UserDefinedTableType, + View, + Table, + HistoryTable, Databases, ExternalResources, ServerLevelSecurity, @@ -130,10 +129,10 @@ public enum NodeTypes SecurityPolicies, DatabaseScopedCredentials, ExternalTables, - ExternalResourceInstance, + ExternalResource, ExternalDataSources, ExternalFileFormats, - ExternalTableInstance, + ExternalTable, AlwaysEncryptedKeys, ColumnMasterKeys, ColumnEncryptionKeys diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs index 11b5e74bc5..85078a2787 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs @@ -8,7 +8,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; -using System.Linq; +using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.Utility; @@ -52,6 +52,12 @@ public TreeNode(string value) /// public string NodeValue { get; set; } + + /// + /// Object metadata for smo objects + /// + public ObjectMetadata ObjectMetadata { get; set; } + /// /// The type of the node - for example Server, Database, Folder, Table /// @@ -170,7 +176,8 @@ public NodeInfo ToNodeInfo() IsLeaf = this.IsAlwaysLeaf, Label = this.Label, NodePath = this.GetNodePath(), - NodeType = this.NodeType + NodeType = this.NodeType, + Metadata = this.ObjectMetadata }; } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs index 3703f7b727..9ddbc94858 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/ServerNode.cs @@ -49,8 +49,8 @@ public ServerNode(ConnectionCompleteParams connInfo, IMultiServiceProvider servi NodeValue = connectionSummary.ServerName; IsAlwaysLeaf = false; - NodeType = NodeTypes.ServerInstance.ToString(); - NodeTypeId = NodeTypes.ServerInstance; + NodeType = NodeTypes.Server.ToString(); + NodeTypeId = NodeTypes.Server; Label = GetConnectionLabel(); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs index d732cd47ed..0448b8a494 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNode.cs @@ -56,6 +56,18 @@ public virtual void CacheInfoFromModel(NamedSmoObject smoObject) { SmoObject = smoObject; NodeValue = smoObject.Name; + ScriptSchemaObjectBase schemaBasecObject = smoObject as ScriptSchemaObjectBase; + ObjectMetadata = new Metadata.Contracts.ObjectMetadata(); + if (schemaBasecObject != null) + { + ObjectMetadata.MetadataTypeName = schemaBasecObject.Urn?.Type; + ObjectMetadata.Name = schemaBasecObject.Name; + ObjectMetadata.Schema = schemaBasecObject.Schema; + if (!string.IsNullOrEmpty(ObjectMetadata.Schema)) + { + NodeValue = $"{ObjectMetadata.Schema}.{smoObject.Name}"; + } + } } public virtual NamedSmoObject GetParentSmoObject() diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml index ea347cb993..94cb77ff82 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml @@ -1,6 +1,6 @@  - + @@ -49,7 +49,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -158,14 +158,14 @@ - + - + @@ -192,7 +192,7 @@ - + @@ -233,7 +233,7 @@ - + @@ -267,7 +267,7 @@ - + @@ -279,7 +279,7 @@ - + @@ -291,13 +291,13 @@ - + - + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs index 759627c143..8e4aff287d 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs @@ -12,8 +12,8 @@ internal sealed partial class DatabaseInstanceTreeNode : SmoTreeNode public DatabaseInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "DatabaseInstance"; - this.NodeTypeId = NodeTypes.DatabaseInstance; + this.NodeType = "Database"; + this.NodeTypeId = NodeTypes.Database; OnInitialize(); } } @@ -23,8 +23,8 @@ internal sealed partial class TableInstanceTreeNode : SmoTreeNode public TableInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "TableInstance"; - this.NodeTypeId = NodeTypes.TableInstance; + this.NodeType = "Table"; + this.NodeTypeId = NodeTypes.Table; OnInitialize(); } } @@ -34,8 +34,8 @@ internal sealed partial class ViewInstanceTreeNode : SmoTreeNode public ViewInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "ViewInstance"; - this.NodeTypeId = NodeTypes.ViewInstance; + this.NodeType = "View"; + this.NodeTypeId = NodeTypes.View; OnInitialize(); } } @@ -45,8 +45,8 @@ internal sealed partial class UserDefinedTableTypeInstanceTreeNode : SmoTreeNode public UserDefinedTableTypeInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "UserDefinedTableTypeInstance"; - this.NodeTypeId = NodeTypes.UserDefinedTableTypeInstance; + this.NodeType = "UserDefinedTableType"; + this.NodeTypeId = NodeTypes.UserDefinedTableType; OnInitialize(); } } @@ -56,8 +56,8 @@ internal sealed partial class StoredProcedureInstanceTreeNode : SmoTreeNode public StoredProcedureInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "StoredProcedureInstance"; - this.NodeTypeId = NodeTypes.StoredProcedureInstance; + this.NodeType = "StoredProcedure"; + this.NodeTypeId = NodeTypes.StoredProcedure; OnInitialize(); } } @@ -67,8 +67,8 @@ internal sealed partial class TableValuedFunctionInstanceTreeNode : SmoTreeNode public TableValuedFunctionInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "TableValuedFunctionInstance"; - this.NodeTypeId = NodeTypes.TableValuedFunctionInstance; + this.NodeType = "TableValuedFunction"; + this.NodeTypeId = NodeTypes.TableValuedFunction; OnInitialize(); } } @@ -78,8 +78,8 @@ internal sealed partial class ScalarValuedFunctionInstanceTreeNode : SmoTreeNode public ScalarValuedFunctionInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "ScalarValuedFunctionInstance"; - this.NodeTypeId = NodeTypes.ScalarValuedFunctionInstance; + this.NodeType = "ScalarValuedFunction"; + this.NodeTypeId = NodeTypes.ScalarValuedFunction; OnInitialize(); } } @@ -89,8 +89,8 @@ internal sealed partial class AggregateFunctionInstanceTreeNode : SmoTreeNode public AggregateFunctionInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "AggregateFunctionInstance"; - this.NodeTypeId = NodeTypes.AggregateFunctionInstance; + this.NodeType = "AggregateFunction"; + this.NodeTypeId = NodeTypes.AggregateFunction; OnInitialize(); } } @@ -111,8 +111,8 @@ internal sealed partial class ExternalTableInstanceTreeNode : SmoTreeNode public ExternalTableInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "ExternalTableInstance"; - this.NodeTypeId = NodeTypes.ExternalTableInstance; + this.NodeType = "ExternalTable"; + this.NodeTypeId = NodeTypes.ExternalTable; OnInitialize(); } } @@ -122,8 +122,8 @@ internal sealed partial class ExternalResourceInstanceTreeNode : SmoTreeNode public ExternalResourceInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "ExternalResourceInstance"; - this.NodeTypeId = NodeTypes.ExternalResourceInstance; + this.NodeType = "ExternalResource"; + this.NodeTypeId = NodeTypes.ExternalResource; OnInitialize(); } } @@ -133,8 +133,8 @@ internal sealed partial class HistoryTableInstanceTreeNode : SmoTreeNode public HistoryTableInstanceTreeNode() : base() { NodeValue = string.Empty; - this.NodeType = "HistoryTableInstance"; - this.NodeTypeId = NodeTypes.HistoryTableInstance; + this.NodeType = "HistoryTable"; + this.NodeTypeId = NodeTypes.HistoryTable; OnInitialize(); } } @@ -143,7 +143,7 @@ public HistoryTableInstanceTreeNode() : base() [Shared] internal partial class ServerInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "ServerInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "Server" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -578,7 +578,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class DatabaseInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "DatabaseInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "Database" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -1147,7 +1147,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class TableInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "TableInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "Table" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -1209,7 +1209,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class HistoryTableInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "HistoryTableInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "HistoryTable" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -1254,7 +1254,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class ExternalTableInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "ExternalTableInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "ExternalTable" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -1454,7 +1454,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class ViewInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "ViewInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "View" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -1875,7 +1875,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class UserDefinedTableTypeInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableTypeInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "UserDefinedTableType" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -2297,7 +2297,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class StoredProcedureInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "StoredProcedureInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "StoredProcedure" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -2375,7 +2375,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class TableValuedFunctionInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "TableValuedFunctionInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "TableValuedFunction" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -2453,7 +2453,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class ScalarValuedFunctionInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "ScalarValuedFunctionInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "ScalarValuedFunction" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { @@ -2531,7 +2531,7 @@ public override TreeNode CreateChild(TreeNode parent, object context) [Shared] internal partial class AggregateFunctionInstanceChildFactory : SmoChildFactoryBase { - public override IEnumerable ApplicableParents() { return new[] { "AggregateFunctionInstance" }; } + public override IEnumerable ApplicableParents() { return new[] { "AggregateFunction" }; } protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs index fd28833417..45221824c8 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -50,7 +50,7 @@ private async Task CreateSessionAndDatabaseNode(string databaseName, O 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 @@ private async Task CreateSessionAndDatabaseNode(string databaseName, O 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 @@ private async Task ExpandTree(NodeInfo node, ObjectExplorerSession session) { 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) diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs index a37babf663..da1870b17d 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs @@ -75,7 +75,7 @@ public void ServerNodeConstructorShouldSetValuesCorrectly() + 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]); diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs index e2fb3a843c..1c6adb77cf 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -103,7 +103,7 @@ public async Task CreateSessionRequestReturnsSuccessAndNodeInfo() 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]); diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs index 9925e566ee..0db97dd27b 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ServiceHost/SrTests.cs @@ -193,7 +193,7 @@ public void SrStringsTest() 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; diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/SrTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/SrTests.cs index 8cd881849e..a629c75086 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/SrTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Utility/SrTests.cs @@ -7,6 +7,8 @@ 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 @@ public void SrPropertiesTest() Assert.NotNull(SR.QueryServiceFileWrapperNotInitialized); Assert.NotNull(SR.QueryServiceColumnNull); - var sr = new ServiceLayerSr(); Assert.NotNull(ServiceLayerSr.ResourceManager); ServiceLayerSr.Culture = CultureInfo.CurrentCulture; Assert.NotNull(ServiceLayerSr.Culture);