In nUnit, we can do something like this:
Expect(actualColleciton, EquivalentTo(expectedCollection));
and
Expect(actualCollection, EqualTo(expectedCollection));
Is there an equivalent in Pester?
I know I can do
$actualCollection | Should Be $expectedCollection
but it does NOT behave as you would expect.
Am I using the right syntax?
I am guessing that you want to compare the contents of your collection, not the pointer/address to the collection.
I think you could inspire from something like:
$a1=@(1,2,3,4,5)
$b1=@(1,2,3,4,5,6)
$ret = (Compare-Object $a1 $b1).InputObject
if ($ret)
{
"different"
}
else
{
"same"
}
to do something like:
$ret = (Compare-Object $actualCollection $expectedCollection).InputObject
$ret | Should Be $null
where $null indicates the lists are the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With