@@ -16,7 +16,7 @@ public class SqlScriptExecutorTests
1616 [ Test ]
1717 public void verify_schema_should_not_check_when_schema_is_null ( )
1818 {
19- var executor = new SqlScriptExecutor ( ( ) => Substitute . For < IConnectionManager > ( ) , ( ) => null , null , ( ) => false , ( ) => false , null ) ;
19+ var executor = new SqlScriptExecutor ( ( ) => Substitute . For < IConnectionManager > ( ) , ( ) => null , null , ( ) => false , null ) ;
2020
2121 executor . VerifySchema ( ) ;
2222 }
@@ -27,7 +27,7 @@ public void when_schema_is_null_schema_is_stripped_from_scripts()
2727 var dbConnection = Substitute . For < IDbConnection > ( ) ;
2828 var command = Substitute . For < IDbCommand > ( ) ;
2929 dbConnection . CreateCommand ( ) . Returns ( command ) ;
30- var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => true , ( ) => false , null ) ;
30+ var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => true , null ) ;
3131
3232 executor . Execute ( new SqlScript ( "Test" , "create $schema$.Table" ) ) ;
3333
@@ -41,7 +41,7 @@ public void uses_variable_subtitute_preprocessor_when_running_scripts()
4141 var dbConnection = Substitute . For < IDbConnection > ( ) ;
4242 var command = Substitute . For < IDbCommand > ( ) ;
4343 dbConnection . CreateCommand ( ) . Returns ( command ) ;
44- var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => true , ( ) => false , null ) ;
44+ var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => true , null ) ;
4545
4646 executor . Execute ( new SqlScript ( "Test" , "create $foo$.Table" ) , new Dictionary < string , string > { { "foo" , "bar" } } ) ;
4747
@@ -55,7 +55,7 @@ public void does_not_use_variable_subtitute_preprocessor_when_setting_false()
5555 var dbConnection = Substitute . For < IDbConnection > ( ) ;
5656 var command = Substitute . For < IDbCommand > ( ) ;
5757 dbConnection . CreateCommand ( ) . Returns ( command ) ;
58- var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => false , ( ) => false , null ) ;
58+ var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , null , ( ) => false , null ) ;
5959
6060 executor . Execute ( new SqlScript ( "Test" , "create $foo$.Table" ) , new Dictionary < string , string > { { "foo" , "bar" } } ) ;
6161
@@ -69,12 +69,30 @@ public void uses_variable_subtitutes_schema()
6969 var dbConnection = Substitute . For < IDbConnection > ( ) ;
7070 var command = Substitute . For < IDbCommand > ( ) ;
7171 dbConnection . CreateCommand ( ) . Returns ( command ) ;
72- var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , "foo" , ( ) => true , ( ) => false , null ) ;
72+ var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true ) , ( ) => new ConsoleUpgradeLog ( ) , "foo" , ( ) => true , null ) ;
7373
7474 executor . Execute ( new SqlScript ( "Test" , "create $schema$.Table" ) ) ;
7575
7676 command . Received ( ) . ExecuteNonQuery ( ) ;
7777 Assert . AreEqual ( "create [foo].Table" , command . CommandText ) ;
7878 }
79+
80+ [ Test ]
81+ public void logs_output_when_configured_to ( )
82+ {
83+ var dbConnection = Substitute . For < IDbConnection > ( ) ;
84+ var command = Substitute . For < IDbCommand > ( ) ;
85+ dbConnection . CreateCommand ( ) . Returns ( command ) ;
86+ var executor = new SqlScriptExecutor ( ( ) => new TestConnectionManager ( dbConnection , true )
87+ {
88+ IsScriptOutputLogged = true
89+ } , ( ) => new ConsoleUpgradeLog ( ) , "foo" , ( ) => true , null ) ;
90+
91+ executor . Execute ( new SqlScript ( "Test" , "create $schema$.Table" ) ) ;
92+
93+ command . Received ( ) . ExecuteReader ( ) ;
94+ command . DidNotReceive ( ) . ExecuteNonQuery ( ) ;
95+ Assert . AreEqual ( "create [foo].Table" , command . CommandText ) ;
96+ }
7997 }
8098}
0 commit comments