@@ -10,13 +10,13 @@ namespace WinHome.Tests;
1010
1111public class CliBuilderTests
1212{
13- private static Func < FileInfo , bool , string ? , bool , bool , bool , bool , bool , bool , LogLevel , Task < int > > NoOpRunAction ( )
13+ private static Func < FileInfo , bool , string ? , bool , bool , bool , bool , bool , bool , bool , LogLevel , Task < int > > NoOpRunAction ( )
1414 {
15- return ( _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) => Task . FromResult ( 0 ) ;
15+ return ( _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) => Task . FromResult ( 0 ) ;
1616 }
1717
1818 private static RootCommand BuildRootCommand (
19- Func < FileInfo , bool , string ? , bool , bool , bool , bool , bool , bool , LogLevel , Task < int > > runAction ,
19+ Func < FileInfo , bool , string ? , bool , bool , bool , bool , bool , bool , bool , LogLevel , Task < int > > runAction ,
2020 Func < FileInfo ? , LogLevel , Task < int > > ? generateAction = null ,
2121 Func < string , string ? , LogLevel , Task < int > > ? stateAction = null )
2222 {
@@ -40,9 +40,10 @@ public async Task RootCommand_BindsOptions()
4040 bool capturedUpdate = false ;
4141 bool capturedForce = false ;
4242 bool capturedContinueOnError = false ;
43+ bool capturedAutoInstall = false ;
4344 LogLevel capturedLevel = LogLevel . Info ;
4445
45- var root = BuildRootCommand ( ( file , dryRun , profile , debug , diff , json , update , force , continueOnError , level ) =>
46+ var root = BuildRootCommand ( ( file , dryRun , profile , debug , diff , json , update , force , continueOnError , autoInstall , level ) =>
4647 {
4748 capturedFile = file ;
4849 capturedDryRun = dryRun ;
@@ -53,6 +54,7 @@ public async Task RootCommand_BindsOptions()
5354 capturedUpdate = update ;
5455 capturedForce = force ;
5556 capturedContinueOnError = continueOnError ;
57+ capturedAutoInstall = autoInstall ;
5658 capturedLevel = level ;
5759 return Task . FromResult ( 0 ) ;
5860 } ) ;
@@ -69,6 +71,7 @@ public async Task RootCommand_BindsOptions()
6971 "--update" ,
7072 "--force" ,
7173 "--continue-on-error" ,
74+ "--auto-install-apps" ,
7275 "--verbose"
7376 } ) . InvokeAsync ( ) ;
7477
@@ -84,6 +87,7 @@ public async Task RootCommand_BindsOptions()
8487 Assert . True ( capturedUpdate ) ;
8588 Assert . True ( capturedForce ) ;
8689 Assert . True ( capturedContinueOnError ) ;
90+ Assert . True ( capturedAutoInstall ) ;
8791 Assert . Equal ( LogLevel . Trace , capturedLevel ) ;
8892 }
8993
@@ -94,23 +98,26 @@ public async Task RootCommand_BindsAliasOptions()
9498 bool capturedDryRun = false ;
9599 string ? capturedProfile = null ;
96100 bool capturedUpdate = false ;
101+ bool capturedAutoInstall = false ;
97102
98- var root = BuildRootCommand ( ( _ , dryRun , profile , _ , _ , _ , update , _ , _ , _ ) =>
103+ var root = BuildRootCommand ( ( _ , dryRun , profile , _ , _ , _ , update , _ , _ , autoInstall , _ ) =>
99104 {
100105 capturedDryRun = dryRun ;
101106 capturedProfile = profile ;
102107 capturedUpdate = update ;
108+ capturedAutoInstall = autoInstall ;
103109 return Task . FromResult ( 0 ) ;
104110 } ) ;
105111
106112 // Act
107- var exitCode = await root . Parse ( new [ ] { "-d" , "-p" , "dev" , "-u" } ) . InvokeAsync ( ) ;
113+ var exitCode = await root . Parse ( new [ ] { "-d" , "-p" , "dev" , "-u" , "-i" } ) . InvokeAsync ( ) ;
108114
109115 // Assert
110116 Assert . Equal ( 0 , exitCode ) ;
111117 Assert . True ( capturedDryRun ) ;
112118 Assert . Equal ( "dev" , capturedProfile ) ;
113119 Assert . True ( capturedUpdate ) ;
120+ Assert . True ( capturedAutoInstall ) ;
114121 }
115122
116123 [ Theory ]
@@ -123,7 +130,7 @@ public async Task RootCommand_LogLevel_Mapping(string option, LogLevel expected)
123130 // Arrange
124131 LogLevel capturedLevel = LogLevel . Info ;
125132
126- var root = BuildRootCommand ( ( _ , _ , _ , _ , _ , _ , _ , _ , _ , level ) =>
133+ var root = BuildRootCommand ( ( _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , level ) =>
127134 {
128135 capturedLevel = level ;
129136 return Task . FromResult ( 0 ) ;
@@ -149,9 +156,10 @@ public async Task RootCommand_DefaultsToFalseAndInfo()
149156 bool capturedUpdate = true ;
150157 bool capturedForce = true ;
151158 bool capturedContinueOnError = true ;
159+ bool capturedAutoInstall = true ;
152160 LogLevel capturedLevel = LogLevel . Trace ;
153161
154- var root = BuildRootCommand ( ( file , dryRun , profile , debug , diff , json , update , force , continueOnError , level ) =>
162+ var root = BuildRootCommand ( ( file , dryRun , profile , debug , diff , json , update , force , continueOnError , autoInstall , level ) =>
155163 {
156164 capturedDryRun = dryRun ;
157165 capturedProfile = profile ;
@@ -161,6 +169,7 @@ public async Task RootCommand_DefaultsToFalseAndInfo()
161169 capturedUpdate = update ;
162170 capturedForce = force ;
163171 capturedContinueOnError = continueOnError ;
172+ capturedAutoInstall = autoInstall ;
164173 capturedLevel = level ;
165174 return Task . FromResult ( 0 ) ;
166175 } ) ;
@@ -178,6 +187,7 @@ public async Task RootCommand_DefaultsToFalseAndInfo()
178187 Assert . False ( capturedUpdate ) ;
179188 Assert . False ( capturedForce ) ;
180189 Assert . False ( capturedContinueOnError ) ;
190+ Assert . False ( capturedAutoInstall ) ;
181191 Assert . Equal ( LogLevel . Info , capturedLevel ) ;
182192 }
183193
@@ -191,7 +201,7 @@ public async Task RootCommand_DefaultConfig_UsesEnvPath()
191201 Environment . SetEnvironmentVariable ( "WINHOME_CONFIG_PATH" , "env-config.yaml" ) ;
192202 FileInfo ? capturedFile = null ;
193203
194- var root = BuildRootCommand ( ( file , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
204+ var root = BuildRootCommand ( ( file , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
195205 {
196206 capturedFile = file ;
197207 return Task . FromResult ( 0 ) ;
@@ -220,7 +230,7 @@ public async Task RootCommand_DefaultConfig_FallsBackToConfigYaml()
220230 Environment . SetEnvironmentVariable ( "WINHOME_CONFIG_PATH" , null ) ;
221231 FileInfo ? capturedFile = null ;
222232
223- var root = BuildRootCommand ( ( file , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
233+ var root = BuildRootCommand ( ( file , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
224234 {
225235 capturedFile = file ;
226236 return Task . FromResult ( 0 ) ;
@@ -245,7 +255,7 @@ public async Task RootCommand_RejectsVerboseAndQuiet()
245255 // Arrange
246256 bool runCalled = false ;
247257
248- var root = BuildRootCommand ( ( _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
258+ var root = BuildRootCommand ( ( _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ) =>
249259 {
250260 runCalled = true ;
251261 return Task . FromResult ( 0 ) ;
0 commit comments