Skip to content

Commit 73d95b9

Browse files
steviecoasterkilasuit
authored andcommitted
Add -Delimiter to ConvertFrom-StringData (PowerShell#10665)
@steviecoaster Thank you!
1 parent b2e6d60 commit 73d95b9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertFrom-StringData.Tests.ps1

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ bazz = 2
6969
Describe "Delimiter parameter tests" -Tags "CI" {
7070
BeforeAll {
7171
$TestCases = @(
72-
@{ Delimiter = ':'; StringData = 'value:10'; ExpectedResult = @{ value = 10 } }
73-
@{ Delimiter = '-'; StringData = 'a-b' ; ExpectedResult = @{ a = 'b' } }
74-
@{ Delimiter = ','; StringData = 'c,d' ; ExpectedResult = @{ c = 'd' } }
72+
@{ Delimiter = ':'; StringData = 'value:10'; ExpectedResult = @{ Values = 10 } }
73+
@{ Delimiter = '-'; StringData = 'a-b' ; ExpectedResult = @{ Values = 'b' } }
74+
@{ Delimiter = ','; StringData = 'c,d' ; ExpectedResult = @{ Values = 'd' } }
7575
)
7676
}
7777

@@ -89,17 +89,14 @@ a:b
8989
{ $sampleData | ConvertFrom-StringData -Delimiter ':' } | Should -Not -Throw
9090
}
9191

92-
It 'is able to parse <StringData> with delimiter "<Delimiter> with <stringdata>"' -TestCases $TestCases {
92+
It 'is able to parse <StringData> with delimiter "<Delimiter>"' -TestCases $TestCases {
9393
param($Delimiter, $StringData, $ExpectedResult)
9494

9595
$Result = ConvertFrom-StringData -StringData $StringData -Delimiter $Delimiter
9696

97-
$key = $ExpectedResult.Keys
98-
99-
# validate the key in expected and result hashtables match
100-
$Result.Keys | Should -BeExactly $ExpectedResult.Keys
101-
102-
# validate the values in expected and result hashtables match
103-
$Result[$key] | Should -BeExactly $ExpectedResult.Values
97+
foreach ($Key in $ExpectedResult.Keys) {
98+
$Key | Should -BeIn $ExpectedResult.Keys
99+
$Result.$Key | Should -Be $ExpectedResult.$Key
100+
}
104101
}
105102
}

0 commit comments

Comments
 (0)