Exemple #1
0
        public void GetDefinitionUsingDeclarationItemWithoutConnectionTest()
        {
            Scripter peekDefinition = new Scripter(null, null);
            string   objectName     = "tableName";
            string   fullObjectName = "master.dbo.tableName";

            Assert.Throws <NullReferenceException>(() => peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Table, fullObjectName, objectName, null));
        }
        public void GetDefinitionUsingDeclarationItemWithoutConnectionTest()
        {
            Scripter         peekDefinition = new Scripter(null, null);
            string           objectName     = "tableName";
            string           fullObjectName = "master.dbo.tableName";
            DefinitionResult result         = peekDefinition.GetDefinitionUsingDeclarationType(DeclarationType.Table, fullObjectName, objectName, null);

            Assert.NotNull(result);
            Assert.True(result.IsErrorResult);
        }
        public void GetDefinitionUsingDeclarationTypeWithNonexistentObjectTest()
        {
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "doesNotExist";
            string   schemaName = "sys";

            DefinitionResult result = scripter.GetDefinitionUsingDeclarationType(DeclarationType.View, "master.sys.objects", objectName, schemaName);

            Assert.NotNull(result);
            Assert.True(result.IsErrorResult);
        }
        public void GetUnsupportedDefinitionErrorTest()
        {
            ConnectionInfo   connInfo         = LiveConnectionHelper.InitLiveConnectionInfoForDefinition();
            ServerConnection serverConnection = LiveConnectionHelper.InitLiveServerConnectionForDefinition(connInfo);

            Scripter scripter   = new Scripter(serverConnection, connInfo);
            string   objectName = "objects";
            string   schemaName = "sys";
            // When I try to get definition for 'Collation'
            DefinitionResult result = scripter.GetDefinitionUsingDeclarationType(DeclarationType.Collation, "master.sys.objects", objectName, schemaName);

            // Then I expect non null result with error flag set
            Assert.NotNull(result);
            Assert.True(result.IsErrorResult);
        }