Esempio n. 1
0
        public void ServerNodeContextShouldSetErrorMessageIfSqlConnectionIsNull()
        {
            // given a connectionInfo with no SqlConnection to use for queries

            Server     smoServer = null;
            ServerNode node      = SetupServerNodeWithServer(smoServer);

            // When I get the context for a ServerNode
            var context = node.GetContextAs <SmoQueryContext>();

            // Then I expect it to be in an error state
            Assert.Null(context);
        }
Esempio n. 2
0
        public void ServerNodeContextShouldSetErrorMessageIfExceptionThrown()
        {
            // given a connectionInfo with no SqlConnection to use for queries
            Server     smoServer   = new Server(new ServerConnection(new SqlConnection(fakeConnectionString)));
            string     expectedMsg = "Failed!";
            ServerNode node        = SetupServerNodeWithExceptionCreator(new Exception(expectedMsg));

            // When I get the context for a ServerNode
            var context = node.GetContextAs <SmoQueryContext>();

            // Then I expect it to be in an error state
            Assert.Null(context);
            Assert.Equal(
                string.Format(CultureInfo.CurrentCulture, SR.TreeNodeError, expectedMsg),
                node.ErrorStateMessage);
        }
Esempio n. 3
0
        public void ServerNodeContextShouldIncludeServer()
        {
            // given a successful Server creation
            Server     smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString)));
            ServerNode node      = SetupServerNodeWithServer(smoServer);

            // When I get the context for a ServerNode
            var context = node.GetContextAs <SmoQueryContext>();

            // Then I expect it to contain the server I created
            Assert.NotNull(context);
            Assert.Equal(smoServer, context.Server);
            // And the server should be the parent
            Assert.Equal(smoServer, context.Parent);
            Assert.Null(context.Database);
        }
Esempio n. 4
0
        public void ServerNodeContextShouldSetErrorMessageIfSqlConnectionIsNull()
        {
            // given a connectionInfo with no SqlConnection to use for queries
            ConnectionService connService = SetupAndRegisterTestConnectionService();

            connService.OwnerToConnectionMap.Remove(defaultOwnerUri);

            Server     smoServer = new Server(new ServerConnection(new SqlConnection(fakeConnectionString)));
            ServerNode node      = SetupServerNodeWithServer(smoServer);

            // When I get the context for a ServerNode
            var context = node.GetContextAs <SmoQueryContext>();

            // Then I expect it to be in an error state
            Assert.Null(context);
            Assert.Equal(
                string.Format(CultureInfo.CurrentCulture, SR.ServerNodeConnectionError, defaultConnectionDetails.ServerName),
                node.ErrorStateMessage);
        }