Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Assert-ArrayEquality($test, $expected) {
$test | Should -HaveCount $expected.Count
0..($test.Count - 1) | % {$test[$_] | Should -Be $expected[$_]}
}
function Assert-HashtableEquality($test, $expected) {
$test.Keys | Should -HaveCount $expected.Keys.Count
$test.Keys | % {$test[$_] | Should -Be $expected[$_]}
}
function Assert-ObjectEquality($test, $expected) {
$testKeys = $test.psobject.Properties | % Name
$expectedKeys = $expected.psobject.Properties | % Name
$testKeys | Should -HaveCount $expectedKeys.Count
$testKeys | % {$test.$_ | Should -Be $expected.$_}
}
@cadegenn
Copy link

cadegenn commented May 10, 2020

Hi, thank you for sharing the code !
I think line 13 should be "$expectedKeys = $expected.psobject.Properties | % Name" if I am not wrong ?

@chriskuech
Copy link
Author

chriskuech commented May 11, 2020

Thanks it's been updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment