mirror of
https://github.com/PowerShell/PSDesiredStateConfiguration
synced 2026-06-21 13:45:25 +00:00
* Fixed an issue with array parameters is key-value pairs (#128) * Add hashtable property to xTestClassResource * Add support for Hashtable property in DSC resource tests
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
### Main changes
|
||||
|
||||
- Fixed Invoke-DscResource error when a class-based resource module path contains a space.
|
||||
- Fixed an issue with array parameters is key-value pairs (#128).
|
||||
|
||||
[v2.0.7]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ function ConvertTo-MOFInstance
|
||||
$targetTypeName = $PropertyTypes[$p.Name].TypeConstraint
|
||||
|
||||
# see if the target type is an array
|
||||
$asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array'
|
||||
$asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array' -or ((-not [string]::IsNullOrEmpty($targetTypeName)) -and $targetTypeName.EndsWith('[]'))
|
||||
|
||||
# Convert the CIM typename to the appropriate .NET type to use
|
||||
# to convert the input object into an appropriately encoded string
|
||||
|
||||
@@ -302,6 +302,8 @@ Describe "All types DSC resource tests" {
|
||||
"uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
|
||||
"uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
|
||||
"uInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64[]]'}
|
||||
|
||||
"HashTableValue" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Hashtable]'}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,6 +352,8 @@ Describe "All types DSC resource tests" {
|
||||
$resource.uInt64Value.GetType().Name | Should -Be "UInt64"
|
||||
$resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
|
||||
|
||||
$resource.HashTableValue.GetType().Name | Should -Be "Hashtable"
|
||||
|
||||
# extra check for embedded objects
|
||||
$resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
|
||||
$resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
|
||||
@@ -400,6 +404,11 @@ configuration DSCAllTypesConfig
|
||||
sInt32ValueArray = @(-2147483648)
|
||||
uInt64ValueArray = @(18446744073709551615)
|
||||
sInt64ValueArray = @(-9223372036854775808)
|
||||
|
||||
HashTableValue = @{
|
||||
Key1 = 'Value1'
|
||||
Key2 = 'Value2'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,9 @@ class xTestClassResource
|
||||
[DscProperty()]
|
||||
[Char[]] $char16ValueArray;
|
||||
|
||||
[DscProperty()]
|
||||
[hashtable] $HashTableValue;
|
||||
|
||||
[void] Set()
|
||||
{
|
||||
|
||||
@@ -257,6 +260,8 @@ class xTestClassResource
|
||||
$this.Real32ValueArray = [single[]]::new(0)
|
||||
$this.Real64ValueArray = [double[]]::new(0)
|
||||
|
||||
$this.HashTableValue = @{}
|
||||
|
||||
return $this
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user