Пример #1
0
        public void ServerNodeConstructorShouldSetValuesCorrectly()
        {
            // Given a server node with valid inputs
            ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection);

            // Then expect all fields set correctly
            Assert.False(node.IsAlwaysLeaf, "Server node should never be a leaf");
            Assert.Equal(defaultConnectionDetails.ServerName, node.NodeValue);

            string expectedLabel = defaultConnectionDetails.ServerName + " (SQL Server " + defaultServerInfo.ServerVersion + " - "
                                   + defaultConnectionDetails.UserName + ")";

            Assert.Equal(expectedLabel, node.Label);

            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]);
        }
Пример #2
0
        public void ToNodeInfoIncludeAllFields()
        {
            // Given a server connection
            ServerNode node = new ServerNode(defaultConnParams, ServiceProvider, serverConnection);
            // When converting to NodeInfo
            NodeInfo info = node.ToNodeInfo();

            // Then all fields should match
            Assert.Equal(node.IsAlwaysLeaf, info.IsLeaf);
            Assert.Equal(node.Label, info.Label);
            Assert.Equal(node.NodeType, info.NodeType);
            string[] nodePath          = node.GetNodePath().Split(TreeNode.PathPartSeperator);
            string[] nodeInfoPathParts = info.NodePath.Split(TreeNode.PathPartSeperator);
            Assert.Equal(nodePath.Length, nodeInfoPathParts.Length);
            for (int i = 0; i < nodePath.Length; i++)
            {
                Assert.Equal(nodePath[i], nodeInfoPathParts[i]);
            }
        }