File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ enum EnumPropEnumeration {
8
8
Expected
9
9
}
10
10
11
+ enum Ensure {
12
+ Present
13
+ Absent
14
+ }
15
+
11
16
class BaseTestClass
12
17
{
13
18
[DscProperty ()]
@@ -32,6 +37,9 @@ class TestClassResource : BaseTestClass
32
37
[DscProperty ()]
33
38
[PSCredential ] $Credential
34
39
40
+ [DscProperty ()]
41
+ [Ensure ] $Ensure
42
+
35
43
[string ] $NonDscProperty # This property shouldn't be in results data
36
44
37
45
hidden
Original file line number Diff line number Diff line change @@ -274,4 +274,20 @@ Describe 'PowerShell adapter resource tests' {
274
274
$out | Should -Not - BeNullOrEmpty
275
275
$out | Should - BeLike " *ERROR*Credential object 'Credential' requires both 'username' and 'password' properties*"
276
276
}
277
- }
277
+
278
+ It ' Config is able to return proper enum value' {
279
+ $yaml = @"
280
+ `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
281
+ resources:
282
+ - name: Class-resource Info
283
+ type: TestClassResource/TestClassResource
284
+ properties:
285
+ Name: 'TestClassResource'
286
+ Ensure: 'Present'
287
+ "@
288
+
289
+ $out = dsc config get - i $yaml | ConvertFrom-Json
290
+ $LASTEXITCODE | Should - Be 0
291
+ $out.results.result.actualState.result.Ensure | Should - Be ' Present'
292
+ }
293
+ }
Original file line number Diff line number Diff line change @@ -445,7 +445,14 @@ function Invoke-DscOperation {
445
445
' Get' {
446
446
$Result = @ {}
447
447
$raw_obj = $dscResourceInstance.Get ()
448
- $ValidProperties | ForEach-Object { $Result [$_ ] = $raw_obj .$_ }
448
+ $ValidProperties | ForEach-Object {
449
+ if ($raw_obj .$_ -is [System.Enum ]) {
450
+ $Result [$_ ] = $raw_obj .$_.ToString ()
451
+ }
452
+ else {
453
+ $Result [$_ ] = $raw_obj .$_
454
+ }
455
+ }
449
456
$addToActualState.properties = $Result
450
457
}
451
458
' Set' {
@@ -473,7 +480,13 @@ function Invoke-DscOperation {
473
480
$raw_obj_array = $method.Invoke ($null , $null )
474
481
foreach ($raw_obj in $raw_obj_array ) {
475
482
$Result_obj = @ {}
476
- $ValidProperties | ForEach-Object { $Result_obj [$_ ] = $raw_obj .$_ }
483
+ $ValidProperties | ForEach-Object { if ($raw_obj .$_ -is [System.Enum ]) {
484
+ $Result [$_ ] = $raw_obj .$_.ToString ()
485
+ }
486
+ else {
487
+ $Result [$_ ] = $raw_obj .$_
488
+ }
489
+ }
477
490
$resultArray += $Result_obj
478
491
}
479
492
$addToActualState = $resultArray
You can’t perform that action at this time.
0 commit comments