Add more tests for PSForEach and PSWhere methods (#25519)

This commit is contained in:
Dongbo Wang
2025-05-09 11:15:03 -07:00
committed by GitHub
parent 32fd8b170d
commit 52150fd8a7
@@ -204,6 +204,12 @@ Describe "Adapter Tests" -tags "CI" {
It "Can use PSForEach as an alias for the Foreach magic method" {
$x = 5
$x.PSForEach({$_}) | Should -Be 5
$p = $null.PSForEach{"I didn't run"}
$p.GetType().Name | Should -BeExactly 'Collection`1'
$p.Count | Should -BeExactly 0
([pscustomobject]@{ Name = 'bar' }).PSForEach({$_.Name}) | Should -BeExactly 'bar'
}
}
@@ -249,6 +255,12 @@ Describe "Adapter Tests" -tags "CI" {
It "Can use PSWhere as an alias for the Where magic method" {
$x = 5
$x.PSWhere{$true} | Should -Be 5
$p = $null.PSWhere{"I didn't run"}
$p.GetType().Name | Should -BeExactly 'Collection`1'
$p.Count | Should -BeExactly 0
([pscustomobject]@{ Name = 'bar' }).PSWhere({$_.Name}) | ForEach-Object Name | Should -BeExactly 'bar'
}
}
}