@@ -274,6 +274,38 @@ public void ConstructsObjectTypeDynamicParameter()
274
274
Assert . Equal ( parameterSetNames [ 0 ] , parameterAttribute . ParameterSetName ) ;
275
275
}
276
276
277
+ [ Fact ]
278
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
279
+ public void ConstructsArrayTypeDynamicParameter ( )
280
+ {
281
+ string [ ] parameters = { "Name" , "Location" , "Mode" } ;
282
+ string [ ] parameterSetNames = { "__AllParameterSets" } ;
283
+ string key = "ranks" ;
284
+ TemplateFileParameterV1 value = new TemplateFileParameterV1 ( )
285
+ {
286
+ AllowedValues = new List < object > ( )
287
+ {
288
+ JArray . Parse ( "[\" 1\" , \" 3\" , \" 5\" ]" ) ,
289
+ JArray . Parse ( "[\" A\" , \" D\" , \" F\" ]" ) ,
290
+ } ,
291
+ DefaultValue = JArray . Parse ( "[\" A\" , \" D\" , \" F\" ]" ) ,
292
+ Type = "array"
293
+ } ;
294
+ KeyValuePair < string , TemplateFileParameterV1 > parameter = new KeyValuePair < string , TemplateFileParameterV1 > ( key , value ) ;
295
+
296
+ RuntimeDefinedParameter dynamicParameter = galleryTemplatesClient . ConstructDynamicParameter ( parameters , parameter ) ;
297
+
298
+ Assert . Equal ( "ranks" , dynamicParameter . Name ) ;
299
+ Assert . Equal ( value . DefaultValue , dynamicParameter . Value ) ;
300
+ Assert . Equal ( typeof ( object [ ] ) , dynamicParameter . ParameterType ) ;
301
+ Assert . Equal ( 1 , dynamicParameter . Attributes . Count ) ;
302
+
303
+ ParameterAttribute parameterAttribute = ( ParameterAttribute ) dynamicParameter . Attributes [ 0 ] ;
304
+ Assert . False ( parameterAttribute . Mandatory ) ;
305
+ Assert . True ( parameterAttribute . ValueFromPipelineByPropertyName ) ;
306
+ Assert . Equal ( parameterSetNames [ 0 ] , parameterAttribute . ParameterSetName ) ;
307
+ }
308
+
277
309
[ Fact ]
278
310
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
279
311
public void GetsDynamicParametersForTemplateFile ( )
@@ -284,7 +316,7 @@ public void GetsDynamicParametersForTemplateFile()
284
316
null ,
285
317
new [ ] { "TestPS" } ) ;
286
318
287
- Assert . Equal ( 6 , result . Count ) ;
319
+ Assert . Equal ( 7 , result . Count ) ;
288
320
289
321
Assert . Equal ( "string" , result [ "string" ] . Name ) ;
290
322
Assert . Equal ( typeof ( string ) , result [ "String" ] . ParameterType ) ;
@@ -303,6 +335,9 @@ public void GetsDynamicParametersForTemplateFile()
303
335
304
336
Assert . Equal ( "secureObject" , result [ "secureObject" ] . Name ) ;
305
337
Assert . Equal ( typeof ( Hashtable ) , result [ "secureObject" ] . ParameterType ) ;
338
+
339
+ Assert . Equal ( "array" , result [ "array" ] . Name ) ;
340
+ Assert . Equal ( typeof ( object [ ] ) , result [ "array" ] . ParameterType ) ;
306
341
}
307
342
308
343
[ Fact ]
@@ -318,14 +353,18 @@ public void GetTemplateParametersFromObject()
318
353
{ "code" , "F1" } ,
319
354
{ "name" , "Free" }
320
355
} ;
356
+ templateParameterObject [ "array" ] = new object [ ] {
357
+ "A" , "D" , "F"
358
+ } ;
359
+
321
360
322
361
RuntimeDefinedParameterDictionary result = galleryTemplatesClient . GetTemplateParametersFromFile (
323
362
templateFile ,
324
363
templateParameterObject ,
325
364
null ,
326
365
new [ ] { "TestPS" } ) ;
327
366
328
- Assert . Equal ( 6 , result . Count ) ;
367
+ Assert . Equal ( 7 , result . Count ) ;
329
368
330
369
Assert . Equal ( "string" , result [ "string" ] . Name ) ;
331
370
Assert . Equal ( typeof ( string ) , result [ "string" ] . ParameterType ) ;
@@ -345,6 +384,13 @@ public void GetTemplateParametersFromObject()
345
384
Assert . Equal ( 2 , objectValue . Count ) ;
346
385
Assert . Equal ( "F1" , objectValue [ "code" ] ) ;
347
386
Assert . Equal ( "Free" , objectValue [ "name" ] ) ;
387
+
388
+ Assert . Equal ( "array" , result [ "array" ] . Name ) ;
389
+ Assert . Equal ( typeof ( object [ ] ) , result [ "array" ] . ParameterType ) ;
390
+ var arrayValue = result [ "array" ] . Value as object [ ] ;
391
+ Assert . Equal ( 3 , arrayValue . Length ) ;
392
+ Assert . Equal ( "A" , arrayValue [ 0 ] ) ;
393
+ Assert . Equal ( "F" , arrayValue [ 2 ] ) ;
348
394
}
349
395
350
396
[ Fact ]
@@ -360,7 +406,7 @@ public void GetTemplateParametersFromFileMergesObjects()
360
406
templateParameterFileSchema1 ,
361
407
new [ ] { "TestPS" } ) ;
362
408
363
- Assert . Equal ( 6 , result . Count ) ;
409
+ Assert . Equal ( 7 , result . Count ) ;
364
410
365
411
Assert . Equal ( "string" , result [ "string" ] . Name ) ;
366
412
Assert . Equal ( typeof ( string ) , result [ "string" ] . ParameterType ) ;
@@ -380,6 +426,13 @@ public void GetTemplateParametersFromFileMergesObjects()
380
426
Assert . Equal ( 2 , objectValue . Count ) ;
381
427
Assert . Equal ( "F1" , objectValue [ "code" ] . ToObject < string > ( ) ) ;
382
428
Assert . Equal ( "Free" , objectValue [ "name" ] . ToObject < string > ( ) ) ;
429
+
430
+ Assert . Equal ( "array" , result [ "array" ] . Name ) ;
431
+ Assert . Equal ( typeof ( object [ ] ) , result [ "array" ] . ParameterType ) ;
432
+ var arrayValue = result [ "array" ] . Value as JArray ;
433
+ Assert . Equal ( 3 , arrayValue . Count ) ;
434
+ Assert . Equal ( "A" , arrayValue [ 0 ] . ToObject < string > ( ) ) ;
435
+ Assert . Equal ( "F" , arrayValue [ 2 ] . ToObject < string > ( ) ) ;
383
436
}
384
437
385
438
[ Fact ]
@@ -395,7 +448,7 @@ public void GetTemplateParametersFromFileWithSchema2MergesObjects()
395
448
templateParameterFileSchema2 ,
396
449
new [ ] { "TestPS" } ) ;
397
450
398
- Assert . Equal ( 6 , result . Count ) ;
451
+ Assert . Equal ( 7 , result . Count ) ;
399
452
400
453
Assert . Equal ( "string" , result [ "string" ] . Name ) ;
401
454
Assert . Equal ( typeof ( string ) , result [ "string" ] . ParameterType ) ;
@@ -415,6 +468,13 @@ public void GetTemplateParametersFromFileWithSchema2MergesObjects()
415
468
Assert . Equal ( 2 , objectValue . Count ) ;
416
469
Assert . Equal ( "F1" , objectValue [ "code" ] . ToObject < string > ( ) ) ;
417
470
Assert . Equal ( "Free" , objectValue [ "name" ] . ToObject < string > ( ) ) ;
471
+
472
+ Assert . Equal ( "array" , result [ "array" ] . Name ) ;
473
+ Assert . Equal ( typeof ( object [ ] ) , result [ "array" ] . ParameterType ) ;
474
+ var arrayValue = result [ "array" ] . Value as JArray ;
475
+ Assert . Equal ( 3 , arrayValue . Count ) ;
476
+ Assert . Equal ( "A" , arrayValue [ 0 ] . ToObject < string > ( ) ) ;
477
+ Assert . Equal ( "F" , arrayValue [ 2 ] . ToObject < string > ( ) ) ;
418
478
}
419
479
420
480
[ Fact ]
0 commit comments