ApplyChangeScript() protected method

Applies the change script.
protected ApplyChangeScript ( ChangeScript script, StringBuilder output ) : void
script ChangeScript The script.
output StringBuilder The output from applying the change script.
return void
Esempio n. 1
0
        public void executar_um_arquivo_de_script_por_vez()
        {
            var dbmsSyntax2  = new Mock <IDbmsSyntax>();
            var changeScript = new Mock <ChangeScript>("Scripts", 1, new FileInfo("script.sql"), Encoding.UTF8);

            dbmsSyntax2.Setup(x => x.CreateChangeLogTableSqlScript(It.IsAny <string>())).Returns("ScriptCreateChangeLog");
            splitter.Setup(s => s.Split(It.IsAny <string>())).Returns <string>(s => new[] { s });
            const string scriptParaExecutar = "script para executar";

            changeScript.Setup(x => x.GetContent()).Returns(scriptParaExecutar);

            var directToDbApplier = new DirectToDbApplier(queryExecuter.Object, schemaVersionManager.Object, splitter.Object, dbmsSyntax2.Object, ChangeLogTableName, System.Console.Out);

            directToDbApplier.ApplyChangeScript(changeScript.Object, true);

            schemaVersionManager.Verify(s => s.RecordScriptStatus(changeScript.Object, ScriptStatus.Started, It.IsAny <string>()), Times.Once);
            queryExecuter.Verify(x => x.BeginTransaction(), Times.Once);
            queryExecuter.Verify(x => x.Execute(scriptParaExecutar, It.IsAny <StringBuilder>()), Times.Once);
            queryExecuter.Verify(e => e.CommitTransaction(), Times.Once());
            schemaVersionManager.Verify(s => s.RecordScriptStatus(changeScript.Object, ScriptStatus.Success, It.IsAny <string>()), Times.Once);
        }
        public void executar_um_arquivo_de_script_por_vez()
        {
            var dbmsSyntax2 = new Mock<IDbmsSyntax>();
            var changeScript = new Mock<ChangeScript>("Scripts", 1, new FileInfo("script.sql"), Encoding.UTF8);
            dbmsSyntax2.Setup(x => x.CreateChangeLogTableSqlScript(It.IsAny<string>())).Returns("ScriptCreateChangeLog");
            splitter.Setup(s => s.Split(It.IsAny<string>())).Returns<string>(s => new[] { s });
            const string scriptParaExecutar = "script para executar";
            changeScript.Setup(x => x.GetContent()).Returns(scriptParaExecutar);

            var directToDbApplier = new DirectToDbApplier(queryExecuter.Object, schemaVersionManager.Object, splitter.Object, dbmsSyntax2.Object, ChangeLogTableName, System.Console.Out);
            directToDbApplier.ApplyChangeScript(changeScript.Object, true);

            schemaVersionManager.Verify(s => s.RecordScriptStatus(changeScript.Object, ScriptStatus.Started, It.IsAny<string>()), Times.Once);
            queryExecuter.Verify(x => x.BeginTransaction(), Times.Once);
            queryExecuter.Verify(x => x.Execute(scriptParaExecutar, It.IsAny<StringBuilder>()), Times.Once);
            queryExecuter.Verify(e => e.CommitTransaction(), Times.Once());
            schemaVersionManager.Verify(s => s.RecordScriptStatus(changeScript.Object, ScriptStatus.Success, It.IsAny<string>()), Times.Once);
        }