@@ -172,5 +172,63 @@ public void TestCommandLineArgsMutuallyExclusiveArgsTest()
172
172
Assert . IsFalse ( parsingSuccessful ) ;
173
173
174
174
}
175
+
176
+ [ TestMethod ]
177
+ public void CacheArgumentTest ( )
178
+ {
179
+ bool parsingSuccessful = false ;
180
+ var trainDataset = Path . GetTempFileName ( ) ;
181
+ var testDataset = Path . GetTempFileName ( ) ;
182
+ var labelName = "Label" ;
183
+ var cache = "on" ;
184
+
185
+ // Create handler outside so that commandline and the handler is decoupled and testable.
186
+ var handler = CommandHandler . Create < NewCommandSettings > (
187
+ ( opt ) =>
188
+ {
189
+ parsingSuccessful = true ;
190
+ Assert . AreEqual ( opt . MlTask , "binary-classification" ) ;
191
+ Assert . AreEqual ( opt . Dataset , trainDataset ) ;
192
+ Assert . AreEqual ( opt . LabelColumnName , labelName ) ;
193
+ Assert . AreEqual ( opt . Cache , cache ) ;
194
+ } ) ;
195
+
196
+ var parser = new CommandLineBuilder ( )
197
+ // Parser
198
+ . AddCommand ( CommandDefinitions . New ( handler ) )
199
+ . UseDefaults ( )
200
+ . Build ( ) ;
201
+
202
+ // valid cache test
203
+ string [ ] args = new [ ] { "new" , "--ml-task" , "binary-classification" , "--dataset" , trainDataset , "--label-column-name" , labelName , "--cache" , cache } ;
204
+ parser . InvokeAsync ( args ) . Wait ( ) ;
205
+ Assert . IsTrue ( parsingSuccessful ) ;
206
+
207
+ parsingSuccessful = false ;
208
+
209
+ cache = "off" ;
210
+ // valid cache test
211
+ args = new [ ] { "new" , "--ml-task" , "binary-classification" , "--dataset" , trainDataset , "--label-column-name" , labelName , "--cache" , cache } ;
212
+ parser . InvokeAsync ( args ) . Wait ( ) ;
213
+ Assert . IsTrue ( parsingSuccessful ) ;
214
+
215
+ parsingSuccessful = false ;
216
+
217
+ cache = "auto" ;
218
+ // valid cache test
219
+ args = new [ ] { "new" , "--ml-task" , "binary-classification" , "--dataset" , trainDataset , "--label-column-name" , labelName , "--cache" , cache } ;
220
+ parser . InvokeAsync ( args ) . Wait ( ) ;
221
+ Assert . IsTrue ( parsingSuccessful ) ;
222
+
223
+ parsingSuccessful = false ;
224
+
225
+ // invalid cache test
226
+ args = new [ ] { "new" , "--ml-task" , "binary-classification" , "--dataset" , trainDataset , "--label-column-name" , labelName , "--cache" , "blah" } ;
227
+ parser . InvokeAsync ( args ) . Wait ( ) ;
228
+ Assert . IsFalse ( parsingSuccessful ) ;
229
+
230
+ File . Delete ( trainDataset ) ;
231
+ File . Delete ( testDataset ) ;
232
+ }
175
233
}
176
234
}
0 commit comments