44using SqlDatabase . Configuration ;
55using SqlDatabase . PowerShell . TestApi ;
66
7- namespace SqlDatabase . PowerShell
7+ namespace SqlDatabase . PowerShell ;
8+
9+ [ TestFixture ]
10+ public class ExecuteCmdLetTest : SqlDatabaseCmdLetTest < ExecuteCmdLet >
811{
9- [ TestFixture ]
10- public class ExecuteCmdLetTest : SqlDatabaseCmdLetTest < ExecuteCmdLet >
12+ [ Test ]
13+ [ TestCase ( "Invoke-SqlDatabase" ) ]
14+ [ TestCase ( "Execute-SqlDatabase" ) ]
15+ public void BuildCommandLine ( string commandName )
1116 {
12- [ Test ]
13- [ TestCase ( "Invoke-SqlDatabase" ) ]
14- [ TestCase ( "Execute-SqlDatabase" ) ]
15- public void BuildCommandLine ( string commandName )
16- {
17- var commandLines = InvokeSqlDatabase (
18- commandName ,
19- c =>
20- {
21- c . Parameters . Add ( nameof ( ExecuteCmdLet . Database ) , "connection string" ) ;
22- c . Parameters . Add ( nameof ( ExecuteCmdLet . From ) , new [ ] { "file 1" , "file 2" } ) ;
23- c . Parameters . Add ( nameof ( ExecuteCmdLet . FromSql ) , new [ ] { "sql text 1" , "sql text 2" } ) ;
24- c . Parameters . Add ( nameof ( ExecuteCmdLet . Transaction ) , TransactionMode . PerStep ) ;
25- c . Parameters . Add ( nameof ( ExecuteCmdLet . Configuration ) , "app.config" ) ;
26- c . Parameters . Add ( nameof ( ExecuteCmdLet . Var ) , new [ ] { "x=1" , "y=2" } ) ;
27- c . Parameters . Add ( nameof ( ExecuteCmdLet . WhatIf ) ) ;
28- c . Parameters . Add ( nameof ( CreateCmdLet . Log ) , "log.txt" ) ;
29- } ) ;
17+ var commandLines = InvokeSqlDatabase (
18+ commandName ,
19+ c =>
20+ {
21+ c . Parameters . Add ( nameof ( ExecuteCmdLet . Database ) , "connection string" ) ;
22+ c . Parameters . Add ( nameof ( ExecuteCmdLet . From ) , new [ ] { "file 1" , "file 2" } ) ;
23+ c . Parameters . Add ( nameof ( ExecuteCmdLet . FromSql ) , new [ ] { "sql text 1" , "sql text 2" } ) ;
24+ c . Parameters . Add ( nameof ( ExecuteCmdLet . Transaction ) , TransactionMode . PerStep ) ;
25+ c . Parameters . Add ( nameof ( ExecuteCmdLet . Configuration ) , "app.config" ) ;
26+ c . Parameters . Add ( nameof ( ExecuteCmdLet . Var ) , new [ ] { "x=1" , "y=2" } ) ;
27+ c . Parameters . Add ( nameof ( ExecuteCmdLet . WhatIf ) ) ;
28+ c . Parameters . Add ( nameof ( CreateCmdLet . Log ) , "log.txt" ) ;
29+ } ) ;
3030
31- commandLines . Length . ShouldBe ( 1 ) ;
32- var commandLine = commandLines [ 0 ] ;
31+ commandLines . Length . ShouldBe ( 1 ) ;
32+ var commandLine = commandLines [ 0 ] ;
3333
34- commandLine . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
35- commandLine . Connection . ShouldBe ( "connection string" ) ;
34+ commandLine . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
35+ commandLine . Connection . ShouldBe ( "connection string" ) ;
3636
37- commandLine . Scripts . Count . ShouldBe ( 2 ) ;
38- Path . IsPathRooted ( commandLine . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
39- Path . GetFileName ( commandLine . Scripts [ 0 ] ) . ShouldBe ( "file 1" ) ;
40- Path . IsPathRooted ( commandLine . Scripts [ 1 ] ) . ShouldBeTrue ( ) ;
41- Path . GetFileName ( commandLine . Scripts [ 1 ] ) . ShouldBe ( "file 2" ) ;
37+ commandLine . Scripts . Count . ShouldBe ( 2 ) ;
38+ Path . IsPathRooted ( commandLine . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
39+ Path . GetFileName ( commandLine . Scripts [ 0 ] ) . ShouldBe ( "file 1" ) ;
40+ Path . IsPathRooted ( commandLine . Scripts [ 1 ] ) . ShouldBeTrue ( ) ;
41+ Path . GetFileName ( commandLine . Scripts [ 1 ] ) . ShouldBe ( "file 2" ) ;
4242
43- commandLine . InLineScript . ShouldBe ( new [ ] { "sql text 1" , "sql text 2" } ) ;
44- commandLine . Transaction . ShouldBe ( TransactionMode . PerStep ) ;
43+ commandLine . InLineScript . ShouldBe ( new [ ] { "sql text 1" , "sql text 2" } ) ;
44+ commandLine . Transaction . ShouldBe ( TransactionMode . PerStep ) ;
4545
46- Path . IsPathRooted ( commandLine . ConfigurationFile ) . ShouldBeTrue ( ) ;
47- Path . GetFileName ( commandLine . ConfigurationFile ) . ShouldBe ( "app.config" ) ;
46+ Path . IsPathRooted ( commandLine . ConfigurationFile ) . ShouldBeTrue ( ) ;
47+ Path . GetFileName ( commandLine . ConfigurationFile ) . ShouldBe ( "app.config" ) ;
4848
49- Path . IsPathRooted ( commandLine . LogFileName ) . ShouldBeTrue ( ) ;
50- Path . GetFileName ( commandLine . LogFileName ) . ShouldBe ( "log.txt" ) ;
49+ Path . IsPathRooted ( commandLine . LogFileName ) . ShouldBeTrue ( ) ;
50+ Path . GetFileName ( commandLine . LogFileName ) . ShouldBe ( "log.txt" ) ;
5151
52- commandLine . WhatIf . ShouldBeTrue ( ) ;
52+ commandLine . WhatIf . ShouldBeTrue ( ) ;
5353
54- commandLine . Variables . Keys . ShouldBe ( new [ ] { "x" , "y" } ) ;
55- commandLine . Variables [ "x" ] . ShouldBe ( "1" ) ;
56- commandLine . Variables [ "y" ] . ShouldBe ( "2" ) ;
57- }
54+ commandLine . Variables . Keys . ShouldBe ( new [ ] { "x" , "y" } ) ;
55+ commandLine . Variables [ "x" ] . ShouldBe ( "1" ) ;
56+ commandLine . Variables [ "y" ] . ShouldBe ( "2" ) ;
57+ }
5858
59- [ Test ]
60- [ TestCase ( "Invoke-SqlDatabase" ) ]
61- [ TestCase ( "Execute-SqlDatabase" ) ]
62- public void BuildPipeCommandLine ( string commandName )
63- {
64- var commandLines = InvokeInvokeSqlDatabasePipeLine (
65- commandName ,
66- c => c . Parameters . Add ( nameof ( ExecuteCmdLet . Database ) , "connection string" ) ,
67- "file 1" ,
68- "file 2" ) ;
59+ [ Test ]
60+ [ TestCase ( "Invoke-SqlDatabase" ) ]
61+ [ TestCase ( "Execute-SqlDatabase" ) ]
62+ public void BuildPipeCommandLine ( string commandName )
63+ {
64+ var commandLines = InvokeInvokeSqlDatabasePipeLine (
65+ commandName ,
66+ c => c . Parameters . Add ( nameof ( ExecuteCmdLet . Database ) , "connection string" ) ,
67+ "file 1" ,
68+ "file 2" ) ;
6969
70- commandLines . Length . ShouldBe ( 2 ) ;
70+ commandLines . Length . ShouldBe ( 2 ) ;
7171
72- commandLines [ 0 ] . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
73- commandLines [ 0 ] . Connection . ShouldBe ( "connection string" ) ;
74- commandLines [ 0 ] . Scripts . Count . ShouldBe ( 1 ) ;
75- Path . IsPathRooted ( commandLines [ 0 ] . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
76- Path . GetFileName ( commandLines [ 0 ] . Scripts [ 0 ] ) . ShouldBe ( "file 1" ) ;
77- commandLines [ 0 ] . InLineScript . Count . ShouldBe ( 0 ) ;
72+ commandLines [ 0 ] . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
73+ commandLines [ 0 ] . Connection . ShouldBe ( "connection string" ) ;
74+ commandLines [ 0 ] . Scripts . Count . ShouldBe ( 1 ) ;
75+ Path . IsPathRooted ( commandLines [ 0 ] . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
76+ Path . GetFileName ( commandLines [ 0 ] . Scripts [ 0 ] ) . ShouldBe ( "file 1" ) ;
77+ commandLines [ 0 ] . InLineScript . Count . ShouldBe ( 0 ) ;
7878
79- commandLines [ 1 ] . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
80- commandLines [ 1 ] . Connection . ShouldBe ( "connection string" ) ;
81- commandLines [ 1 ] . Scripts . Count . ShouldBe ( 1 ) ;
82- Path . IsPathRooted ( commandLines [ 1 ] . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
83- Path . GetFileName ( commandLines [ 1 ] . Scripts [ 0 ] ) . ShouldBe ( "file 2" ) ;
84- commandLines [ 1 ] . InLineScript . Count . ShouldBe ( 0 ) ;
85- }
79+ commandLines [ 1 ] . Command . ShouldBe ( CommandLineFactory . CommandExecute ) ;
80+ commandLines [ 1 ] . Connection . ShouldBe ( "connection string" ) ;
81+ commandLines [ 1 ] . Scripts . Count . ShouldBe ( 1 ) ;
82+ Path . IsPathRooted ( commandLines [ 1 ] . Scripts [ 0 ] ) . ShouldBeTrue ( ) ;
83+ Path . GetFileName ( commandLines [ 1 ] . Scripts [ 0 ] ) . ShouldBe ( "file 2" ) ;
84+ commandLines [ 1 ] . InLineScript . Count . ShouldBe ( 0 ) ;
8685 }
8786}
0 commit comments