Ejemplo n.º 1
0
        public void Execute(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver, bool logOnly = false)
        {
            string scriptFilename = getFilename(fullFilename);
            if (_executionTracker.ScriptAlreadyExecuted(settings, scriptFilename))
            {
                taskObserver.Log(string.Format("Skipping (already executed): {0}{1}", getLastFolderName(fullFilename),scriptFilename));
            }
            else
            {
                if (!logOnly)
                {
                    string sql = _fileSystem.ReadTextFile(fullFilename);
                    if (!ScriptSupportsTransactions(sql))
                    {
                        taskObserver.Log(string.Format("Executing: {0}{1}", getLastFolderName(fullFilename),scriptFilename));
                        _executor.ExecuteNonQuery(settings, sql, true);
                    }
                    else
                    {
                        taskObserver.Log(string.Format("Executing: {0}{1} in a transaction", getLastFolderName(fullFilename),scriptFilename));
                        _executor.ExecuteNonQueryTransactional(settings, sql);
                    }
                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0}{1} in log only mode",getLastFolderName(fullFilename), scriptFilename));
                }

                _executionTracker.MarkScriptAsExecuted(settings, scriptFilename, taskObserver);
            }
        }
Ejemplo n.º 2
0
        public void Execute(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver, bool logOnly = false)
        {
            string scriptFilename = getFilename(fullFilename);

            if (_executionTracker.ScriptAlreadyExecuted(settings, scriptFilename))
            {
                taskObserver.Log(string.Format("Skipping (already executed): {0}{1}", getLastFolderName(fullFilename), scriptFilename));
            }
            else
            {
                if (!logOnly)
                {
                    string sql = _fileSystem.ReadTextFile(fullFilename);
                    if (!_executor.ScriptSupportsTransactions(sql))
                    {
                        taskObserver.Log(string.Format("Executing: {0}{1}", getLastFolderName(fullFilename), scriptFilename));
                        _executor.ExecuteNonQuery(settings, sql, true);
                    }
                    else
                    {
                        taskObserver.Log(string.Format("Executing: {0}{1} in a transaction", getLastFolderName(fullFilename), scriptFilename));
                        _executor.ExecuteNonQueryTransactional(settings, sql);
                    }
                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0}{1} in log only mode", getLastFolderName(fullFilename), scriptFilename));
                }

                _executionTracker.MarkScriptAsExecuted(settings, scriptFilename, taskObserver);
            }
        }
Ejemplo n.º 3
0
        public void ExecuteIfChanged(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver, bool logOnly = false)
        {
            string scriptFilename = getFilename(fullFilename);
            var    scriptFileMD5  = GetFileMD5Hash(fullFilename);

            if (_executionTracker.EverytimeScriptShouldBeExecuted(settings, scriptFilename, scriptFileMD5))
            {
                if (!logOnly)
                {
                    string sql = _fileSystem.ReadTextFile(fullFilename);

                    taskObserver.Log(string.Format("Executing: {0}{1}", getLastFolderName(fullFilename), scriptFilename));
                    _executor.ExecuteNonQuery(settings, sql, true);
                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0}{1} in log only mode", getLastFolderName(fullFilename), scriptFilename));
                }

                _executionTracker.MarkScriptAsExecuted(settings, scriptFilename, taskObserver, scriptFileMD5);
            }
            else
            {
                taskObserver.Log(string.Format("Skipping (unchanged): {0}{1}", getLastFolderName(fullFilename), scriptFilename));
            }
        }
Ejemplo n.º 4
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            if (!_queryExecutor.CheckDatabaseExists(taskAttributes.ConnectionSettings))
            {
                return;
            }

            var version = _queryExecutor.ReadFirstColumnAsStringArray(taskAttributes.ConnectionSettings, "select @@version")[0];

            taskObserver.Log("Running against: " + version);

            //can't kill connections or enter single user mode in Azure
            var sql = string.Format("drop database [{0}]", taskAttributes.ConnectionSettings.Database);

            if (!version.Contains("SQL Azure"))
            {
                _connectionDropper.Drop(taskAttributes.ConnectionSettings, taskObserver);
                sql = string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [{0}]", taskAttributes.ConnectionSettings.Database);
            }

            string message = string.Format("Dropping database: {0}\n", taskAttributes.ConnectionSettings.Database);

            taskObserver.Log(message);
            try
            {
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);
            }
            catch (Exception)
            {
                taskObserver.Log(string.Format("Database '{0}' could not be dropped.", taskAttributes.ConnectionSettings.Database));
            }
        }
Ejemplo n.º 5
0
        public void Execute(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver)
        {
            string scriptFilename = getFilename(fullFilename);

            if (_executionTracker.TestDataScriptAlreadyExecuted(settings, scriptFilename))
            {
                taskObserver.Log(string.Format("Skipping (already executed): {0}", scriptFilename));
            }
            else
            {
                string sql = _fileSystem.ReadTextFile(fullFilename);
                if (!_executor.ScriptSupportsTransactions(sql))
                {
                    taskObserver.Log(string.Format("Executing: {0}", scriptFilename));
                    _executor.ExecuteNonQuery(settings, sql, true);
                    _executionTracker.MarkTestDataScriptAsExecuted(settings, scriptFilename, taskObserver);
                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0} in a transaction", scriptFilename));
                    _executor.ExecuteNonQueryTransactional(settings, sql);
                    _executionTracker.MarkTestDataScriptAsExecuted(settings, scriptFilename, taskObserver);
                }
            }
        }
Ejemplo n.º 6
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            try
            {
                var version = _queryExecutor.ReadFirstColumnAsStringArray(taskAttributes.ConnectionSettings, "select @@version")[0];
                 taskObserver.Log("Running against: " + version);

                //can't kill connections or enter single user mode in Azure
                var sql = string.Format("drop database [{0}]", taskAttributes.ConnectionSettings.Database);
                if (!version.Contains("SQL Azure"))
                {
                    _connectionDropper.Drop(taskAttributes.ConnectionSettings, taskObserver);
                    sql = string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [{0}]", taskAttributes.ConnectionSettings.Database);
                }

                string message = string.Format("Dropping database: {0}\n", taskAttributes.ConnectionSettings.Database);
                taskObserver.Log(message);  
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);
            }
            catch (Exception)
            {
                //if the database doesn't exist just close any open connections and move on
                SqlConnection.ClearAllPools();
                taskObserver.Log(string.Format("Database '{0}' could not be dropped.", taskAttributes.ConnectionSettings.Database));
            }
        }
Ejemplo n.º 7
0
        public void Execute(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver)
        {
            string scriptFilename = getFilename(fullFilename);

            if (_executionTracker.TestDataScriptAlreadyExecuted(settings, scriptFilename))
            {
                taskObserver.Log(string.Format("Skipping (already executed): {0}", scriptFilename));
            }
            else
            {
                string sql = _fileSystem.ReadTextFile(fullFilename);
                if (!_executor.ScriptSupportsTransactions(sql))
                {
                    taskObserver.Log(string.Format("Executing: {0}", scriptFilename));
                    _executor.ExecuteNonQuery(settings, sql, true);
                    _executionTracker.MarkTestDataScriptAsExecuted(settings, scriptFilename, taskObserver);

                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0} in a transaction", scriptFilename));
                    _executor.ExecuteNonQueryTransactional(settings, sql);
                    _executionTracker.MarkTestDataScriptAsExecuted(settings, scriptFilename, taskObserver);
                }
            }
        }
Ejemplo n.º 8
0
        public void ExecuteIfChanged(string fullFilename, ConnectionSettings settings, ITaskObserver taskObserver, bool logOnly = false)
        {
            string scriptFilename = getFilename(fullFilename);
            var scriptFileMD5 = GetFileMD5Hash(fullFilename);
           
            if (_executionTracker.EverytimeScriptShouldBeExecuted(settings, scriptFilename, scriptFileMD5))
            {
                if (!logOnly)
                {
                    string sql = _fileSystem.ReadTextFile(fullFilename);

                    taskObserver.Log(string.Format("Executing: {0}{1}", getLastFolderName(fullFilename), scriptFilename));
                    _executor.ExecuteNonQuery(settings, sql, true);
                }
                else
                {
                    taskObserver.Log(string.Format("Executing: {0}{1} in log only mode", getLastFolderName(fullFilename), scriptFilename));
                }

                _executionTracker.MarkScriptAsExecuted(settings, scriptFilename, taskObserver, scriptFileMD5);
            }
            else
            {
                taskObserver.Log(string.Format("Skipping (unchanged): {0}{1}", getLastFolderName(fullFilename), scriptFilename));
            }
        }
Ejemplo n.º 9
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            string sql = string.Format("create database [{0}]", taskAttributes.ConnectionSettings.Database);

            _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);

            taskObserver.Log(string.Format("Run scripts in Create folder."));
            _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Create", taskObserver);

            taskObserver.Log(string.Format("Run scripts in Everytime folder."));
            _folderExecutor.ExecuteChangedScriptsInFolder(taskAttributes, "Everytime", taskObserver);
        }
Ejemplo n.º 10
0
        public void RunsScriptsWithTransactionalStopWordsNonTransactional()
        {
            ConnectionSettings settings     = getConnectionSettings();
            string             scriptFile   = @"c:\scripts\Update\01_Test.sql";
            string             fileContents = "CREATE DATABASE ...";

            MockRepository          mocks            = new MockRepository();
            IScriptExecutionTracker executionTracker = mocks.StrictMock <IScriptExecutionTracker>();
            IFileSystem             fileSystem       = mocks.StrictMock <IFileSystem>();
            IQueryExecutor          queryExecutor    = mocks.StrictMock <IQueryExecutor>();
            ITaskObserver           taskObserver     = mocks.StrictMock <ITaskObserver>();

            Expect.Call(executionTracker.ScriptAlreadyExecuted(settings, "01_Test.sql")).Return(false);
            taskObserver.Log("Executing: 01_Test.sql");
            Expect.Call(fileSystem.ReadTextFile(scriptFile)).Return(fileContents);
            Expect.Call(queryExecutor.ScriptSupportsTransactions(fileContents)).Return(false);
            queryExecutor.ExecuteNonQuery(settings, fileContents, true);
            executionTracker.MarkScriptAsExecuted(settings, "01_Test.sql", taskObserver);

            mocks.ReplayAll();

            IChangeScriptExecutor executor = new ChangeScriptExecutor(executionTracker, queryExecutor, fileSystem);

            executor.Execute(scriptFile, settings, taskObserver);

            mocks.VerifyAll();
        }
        public void Correctly_drops_connections()
        {
            string assembly = SqlDatabaseManager.SQL_FILE_ASSEMBLY;
            string sqlFile  = string.Format(SqlDatabaseManager.SQL_FILE_TEMPLATE, "DropConnections");

            ConnectionSettings settings = new ConnectionSettings("server", "MyDatabase", true, null, null);

            MockRepository mocks = new MockRepository();

            ITaskObserver        taskObserver  = mocks.CreateMock <ITaskObserver>();
            IResourceFileLocator fileLocator   = mocks.CreateMock <IResourceFileLocator>();
            ITokenReplacer       replacer      = mocks.CreateMock <ITokenReplacer>();
            IQueryExecutor       queryExecutor = mocks.CreateMock <IQueryExecutor>();

            using (mocks.Record())
            {
                taskObserver.Log("Dropping connections for database MyDatabase\n");
                Expect.Call(fileLocator.ReadTextFile(assembly, sqlFile)).Return("Unformatted SQL");
                replacer.Text = "Unformatted SQL";
                replacer.Replace("DatabaseName", "MyDatabase");
                Expect.Call(replacer.Text).Return("Formatted SQL");
                queryExecutor.ExecuteNonQuery(settings, "Formatted SQL", false);
            }

            using (mocks.Playback())
            {
                IDatabaseConnectionDropper dropper = new DatabaseConnectionDropper(fileLocator, replacer, queryExecutor);
                dropper.Drop(settings, taskObserver);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 12
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            if (!_queryExecutor.CheckDatabaseExists(taskAttributes.ConnectionSettings))
            {
                taskObserver.Log(string.Format("Database does not exist. Attempting to create database before updating."));
                string sql = string.Format("create database [{0}]", taskAttributes.ConnectionSettings.Database);
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);
                taskObserver.Log(string.Format("Run scripts in Create folder."));
                _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Create", taskObserver);
            }
            taskObserver.Log(string.Format("Run scripts in Update folder."));
            _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Update", taskObserver);

            taskObserver.Log(string.Format("Run scripts in Everytime folder."));
            _folderExecutor.ExecuteChangedScriptsInFolder(taskAttributes, "Everytime", taskObserver);
        }
Ejemplo n.º 13
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            if (!_queryExecutor.CheckDatabaseExists(taskAttributes.ConnectionSettings))
            {
                taskObserver.Log(string.Format("Database does not exist. Attempting to create database before updating."));
                string sql = string.Format("create database [{0}]", taskAttributes.ConnectionSettings.Database);
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);
                 taskObserver.Log(string.Format("Run scripts in Create folder."));
                _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Create", taskObserver);
            }
            taskObserver.Log(string.Format("Run scripts in Update folder."));
            _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Update", taskObserver);

            taskObserver.Log(string.Format("Run scripts in Everytime folder."));
            _folderExecutor.ExecuteChangedScriptsInFolder(taskAttributes, "Everytime", taskObserver);
        }
Ejemplo n.º 14
0
        public void CorrectlyExecutesScriptIfItHasntAlreadyBeenExecuted()
        {
            ConnectionSettings settings     = getConnectionSettings();
            string             scriptFile   = @"c:\scripts\Update\01_Test.sql";
            string             fileContents = "file contents...";

            MockRepository          mocks            = new MockRepository();
            IScriptExecutionTracker executionTracker = mocks.CreateMock <IScriptExecutionTracker>();
            IFileSystem             fileSystem       = mocks.CreateMock <IFileSystem>();
            IQueryExecutor          queryExecutor    = mocks.CreateMock <IQueryExecutor>();
            ITaskObserver           taskObserver     = mocks.CreateMock <ITaskObserver>();

            Expect.Call(executionTracker.ScriptAlreadyExecuted(settings, "01_Test.sql")).Return(false);
            taskObserver.Log("Executing: 01_Test.sql");
            Expect.Call(fileSystem.ReadTextFile(scriptFile)).Return(fileContents);
            queryExecutor.ExecuteNonQuery(settings, fileContents, true);
            executionTracker.MarkScriptAsExecuted(settings, "01_Test.sql", taskObserver);

            mocks.ReplayAll();

            IChangeScriptExecutor executor = new ChangeScriptExecutor(executionTracker, queryExecutor, fileSystem);

            executor.Execute(scriptFile, settings, taskObserver);

            mocks.VerifyAll();
        }
Ejemplo n.º 15
0
        public void CorrectlyExecutesScriptIfItHasntAlreadyBeenExecuted()
        {
            var    settings     = new ConnectionSettings("server", "db", true, null, null);
            string scriptFile   = @"c:\scripts\TestData\01_Test.sql";
            string fileContents = "file contents...";

            MockRepository          mocks            = new MockRepository();
            IScriptExecutionTracker executionTracker = mocks.StrictMock <IScriptExecutionTracker>();
            IFileSystem             fileSystem       = mocks.StrictMock <IFileSystem>();
            IQueryExecutor          queryExecutor    = mocks.StrictMock <IQueryExecutor>();
            ITaskObserver           taskObserver     = mocks.StrictMock <ITaskObserver>();

            Expect.Call(executionTracker.TestDataScriptAlreadyExecuted(settings, "01_Test.sql")).Return(false);
            taskObserver.Log("Executing: 01_Test.sql in a transaction");
            Expect.Call(fileSystem.ReadTextFile(scriptFile)).Return(fileContents);
            Expect.Call(queryExecutor.ScriptSupportsTransactions(fileContents)).Return(true);
            queryExecutor.ExecuteNonQueryTransactional(settings, fileContents);
            executionTracker.MarkTestDataScriptAsExecuted(settings, "01_Test.sql", taskObserver);

            mocks.ReplayAll();

            ITestDataScriptExecutor executor = new TestDataScriptExecutor(executionTracker, queryExecutor, fileSystem);

            executor.Execute(scriptFile, settings, taskObserver);

            mocks.VerifyAll();
        }
Ejemplo n.º 16
0
	    public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
		{
            string sql = string.Format("create database [{0}]", taskAttributes.ConnectionSettings.Database);
            _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql);

            taskObserver.Log(string.Format("Run scripts in Create folder."));
            _folderExecutor.ExecuteScriptsInFolder(taskAttributes, "Create", taskObserver);
		}
Ejemplo n.º 17
0
	    public void Upgrade(TaskAttributes taskAttributes, ITaskObserver taskObserver)
		{
            string initializationMessage = _logMessageGenerator.GetInitialMessage(taskAttributes);
			taskObserver.Log(initializationMessage);

            IEnumerable<IDatabaseActionExecutor> executors = _actionExecutorFactory.GetExecutors(taskAttributes.RequestedDatabaseAction);

			foreach (IDatabaseActionExecutor executor in executors)
			{
                executor.Execute(taskAttributes, taskObserver);
			}
		}
Ejemplo n.º 18
0
        public void Upgrade(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            string initializationMessage = _logMessageGenerator.GetInitialMessage(taskAttributes);

            taskObserver.Log(initializationMessage);

            IEnumerable <IDatabaseActionExecutor> executors = _actionExecutorFactory.GetExecutors(taskAttributes.RequestedDatabaseAction);

            foreach (IDatabaseActionExecutor executor in executors)
            {
                executor.Execute(taskAttributes, taskObserver);
            }
        }
Ejemplo n.º 19
0
		public void Import(string excelFile, string server, string database, bool integrated, string username, string password,
		                   ITaskObserver taskObserver)
		{
			string message = string.Format("\nImporting Excel File '{0}' to Database '{1}' on Server '{2}'\n", excelFile, database, server);
			taskObserver.Log(message);
			var settings = new ConnectionSettings(server, database, integrated, username, password);

			string sql = _fileLocator.ReadTextFile("Tarantino.Core", "Tarantino.Core.DatabaseManager.SqlFiles.ImportExcel.sql");
			_tokenReplacer.Text = sql;
			_tokenReplacer.Replace("DATABASE", database);
			_tokenReplacer.Replace("EXCEL_FILE", excelFile);
			_queryExecutor.ExecuteNonQuery(settings, _tokenReplacer.Text, false);
		}
Ejemplo n.º 20
0
        public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
        {
            _connectionDropper.Drop(taskAttributes.ConnectionSettings, taskObserver);
            var sql = string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [{0}]", taskAttributes.ConnectionSettings.Database);

            try
            {
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql, false);
            }
            catch (Exception)
            {
                taskObserver.Log(string.Format("Database '{0}' could not be dropped.", taskAttributes.ConnectionSettings.Database));
            }
        }
Ejemplo n.º 21
0
	    public void Execute(TaskAttributes taskAttributes, ITaskObserver taskObserver)
		{
	               _connectionDropper.Drop(taskAttributes.ConnectionSettings, taskObserver);
			var sql = string.Format("ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE drop database [{0}]", taskAttributes.ConnectionSettings.Database);

			try
			{
                _queryExecutor.ExecuteNonQuery(taskAttributes.ConnectionSettings, sql, false);
			}
			catch(Exception)
			{
				taskObserver.Log(string.Format("Database '{0}' could not be dropped.", taskAttributes.ConnectionSettings.Database));
			}
		}
Ejemplo n.º 22
0
        public void Import(string excelFile, string server, string database, bool integrated, string username, string password,
                           ITaskObserver taskObserver)
        {
            string message = string.Format("\nImporting Excel File '{0}' to Database '{1}' on Server '{2}'\n", excelFile, database, server);

            taskObserver.Log(message);
            var settings = new ConnectionSettings(server, database, integrated, username, password);

            string sql = _fileLocator.ReadTextFile("Tarantino.Core", "Tarantino.Core.DatabaseManager.SqlFiles.ImportExcel.sql");

            _tokenReplacer.Text = sql;
            _tokenReplacer.Replace("DATABASE", database);
            _tokenReplacer.Replace("EXCEL_FILE", excelFile);
            _queryExecutor.ExecuteNonQuery(settings, _tokenReplacer.Text, false);
        }
Ejemplo n.º 23
0
	    public void Drop(ConnectionSettings settings, ITaskObserver taskObserver)
		{
			string message = string.Format("Dropping connections for database {0}\n", settings.Database);
			taskObserver.Log(message);

			string assembly = SqlDatabaseManager.SQL_FILE_ASSEMBLY;
			string sqlFile = string.Format(SqlDatabaseManager.SQL_FILE_TEMPLATE, "DropConnections");

			string sql = _fileLocator.ReadTextFile(assembly, sqlFile);

			_replacer.Text = sql;
			_replacer.Replace("DatabaseName", settings.Database);
			sql = _replacer.Text;

			_executor.ExecuteNonQuery(settings, sql);
		}
Ejemplo n.º 24
0
        public void Drop(ConnectionSettings settings, ITaskObserver taskObserver)
        {
            string message = string.Format("Dropping connections for database {0}\n", settings.Database);

            taskObserver.Log(message);

            string assembly = SqlDatabaseManager.SQL_FILE_ASSEMBLY;
            string sqlFile  = string.Format(SqlDatabaseManager.SQL_FILE_TEMPLATE, "DropConnections");

            string sql = _fileLocator.ReadTextFile(assembly, sqlFile);

            _replacer.Text = sql;
            _replacer.Replace("DatabaseName", settings.Database);
            sql = _replacer.Text;

            _executor.ExecuteNonQuery(settings, sql, false);
        }
Ejemplo n.º 25
0
        public void CorrectlyLogsWarningWhenScriptHasAlreadyBeenExecuted()
        {
            ConnectionSettings settings   = getConnectionSettings();
            string             scriptFile = @"c:\scripts\Update\01_Test.sql";

            MockRepository          mocks            = new MockRepository();
            IScriptExecutionTracker executionTracker = mocks.CreateMock <IScriptExecutionTracker>();
            ITaskObserver           taskObserver     = mocks.CreateMock <ITaskObserver>();

            Expect.Call(executionTracker.ScriptAlreadyExecuted(settings, "01_Test.sql")).Return(true);
            taskObserver.Log("Skipping (already executed): 01_Test.sql");

            mocks.ReplayAll();

            IChangeScriptExecutor executor = new ChangeScriptExecutor(executionTracker, null, null);

            executor.Execute(scriptFile, settings, taskObserver);

            mocks.VerifyAll();
        }
Ejemplo n.º 26
0
        public void DoesNotExecuteScriptsInBaseLineMode()
        {
            ConnectionSettings settings   = getConnectionSettings();
            string             scriptFile = @"c:\scripts\Update\01_Test.sql";

            MockRepository          mocks            = new MockRepository();
            IScriptExecutionTracker executionTracker = mocks.StrictMock <IScriptExecutionTracker>();
            ITaskObserver           taskObserver     = mocks.StrictMock <ITaskObserver>();

            DoNotExpect.Call(executionTracker.ScriptAlreadyExecuted(settings, "01_Test.sql"));
            taskObserver.Log("Skipping (already executed): 01_Test.sql");

            mocks.ReplayAll();

            IChangeScriptExecutor executor = new ChangeScriptExecutor(executionTracker, null, null);

            executor.Execute(scriptFile, settings, taskObserver);

            mocks.VerifyAll();
        }