Beispiel #1
0
        private void ValidatePeekTest(string databaseName, string objectName, string objectType, string schemaName, bool shouldReturnValidResult)
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition(databaseName);
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter = new Scripter(serverConnection, connInfo);

            Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
            if (shouldReturnValidResult)
            {
                Assert.NotNull(locations);
                Cleanup(locations);
            }
            else
            {
                Assert.Null(locations);
            }

            var connectionService = LiveConnectionHelper.GetLiveTestConnectionService();

            connectionService.Disconnect(new DisconnectParams
            {
                OwnerUri = connInfo.OwnerUri
            });
        }
        public void GetStoredProcedureDefinitionFailureTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "SP2";
            string   schemaName = "dbo";
            string   objectType = "PROCEDURE";

            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
            Assert.Null(locations);
        }
        public void GetViewDefinitionInvalidObjectTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "objects";
            string   schemaName = null;
            string   objectType = "VIEW";

            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
            Assert.Null(locations);
        }
        public void GetValidViewDefinitionTest()
        {
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "objects";
            string   schemaName = "sys";
            string   objectType = "VIEW";

            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
            Assert.NotNull(locations);
            Cleanup(locations);
        }
        public void GetStoredProcedureDefinitionWithoutSchemaTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "sp_MSrepl_startup";
            string   schemaName = null;
            string   objectType = "PROCEDURE";

            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
            Assert.NotNull(locations);
            Cleanup(locations);
        }
        public void GetTableDefinitionInvalidObjectTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "test_invalid";
            string   schemaName = null;
            string   objectType = "TABLE";

            // Get locations for invalid table object
            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
            Assert.Null(locations);
        }
Beispiel #7
0
        public void GetStoredProcedureDefinitionTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "sp_columns";

            string schemaName = "sys";
            string objectType = "StoredProcedure";

            Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
            Assert.NotNull(locations);
            Cleanup(locations);
        }
        public void GetTableDefinitionWithSchemaTest()
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "spt_monitor";

            string schemaName = "dbo";
            string objectType = "TABLE";

            // Get locations for valid table object with schema name
            Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
            Assert.NotNull(locations);
            Cleanup(locations);
        }
        private void ValidatePeekTest(string databaseName, string objectName, string objectType, string schemaName, bool shouldReturnValidResult)
        {
            // Get live connectionInfo and serverConnection
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition(databaseName);
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter = new Scripter(serverConnection, connInfo);

            Scripter.ScriptGetter sqlScriptGetter = null;
            switch (objectType)
            {
            case SynonymTypeName:
                sqlScriptGetter = scripter.GetSynonymScripts;
                break;

            case ScalarValuedFunctionTypeName:
                sqlScriptGetter = scripter.GetScalarValuedFunctionScripts;
                objectType      = "Function";
                break;

            case TableValuedFunctionTypeName:
                sqlScriptGetter = scripter.GetTableValuedFunctionScripts;
                objectType      = "Function";
                break;

            case TableTypeName:
                sqlScriptGetter = scripter.GetTableScripts;
                break;

            case ViewTypeName:
                sqlScriptGetter = scripter.GetViewScripts;
                break;

            case StoredProcedureTypeName:
                sqlScriptGetter = scripter.GetStoredProcedureScripts;
                break;

            case UserDefinedDataTypeTypeName:
                sqlScriptGetter = scripter.GetUserDefinedDataTypeScripts;
                objectType      = "Type";
                break;

            case UserDefinedTableTypeTypeName:
                sqlScriptGetter = scripter.GetUserDefinedTableTypeScripts;
                objectType      = "Type";
                break;
            }

            Location[] locations = scripter.GetSqlObjectDefinition(sqlScriptGetter, objectName, schemaName, objectType);
            if (shouldReturnValidResult)
            {
                Assert.NotNull(locations);
                Cleanup(locations);
            }
            else
            {
                Assert.Null(locations);
            }

            var connectionService = LiveConnectionHelper.GetLiveTestConnectionService();

            connectionService.Disconnect(new DisconnectParams
            {
                OwnerUri = connInfo.OwnerUri
            });
        }