Skip to content

Instantly share code, notes, and snippets.

@chriskuech
Last active May 11, 2020 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskuech/cb86e8fddc6cca21ccffbe664ecdd803 to your computer and use it in GitHub Desktop.
Save chriskuech/cb86e8fddc6cca21ccffbe664ecdd803 to your computer and use it in GitHub Desktop.
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

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

Thanks it's been updated

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