在 nUnit 中,我们可以这样做:
Expect(actualColleciton, EquivalentTo(expectedCollection));
和
Expect(actualCollection, EqualTo(expectedCollection));
Pester 中是否有等价物?
我知道我能做到
$actualCollection | Should Be $expectedCollection
但它的行为并不像您期望的那样。
我使用正确的语法吗?
在 nUnit 中,我们可以这样做:
Expect(actualColleciton, EquivalentTo(expectedCollection));
和
Expect(actualCollection, EqualTo(expectedCollection));
Pester 中是否有等价物?
我知道我能做到
$actualCollection | Should Be $expectedCollection
但它的行为并不像您期望的那样。
我使用正确的语法吗?
我猜您想比较集合的内容,而不是集合的指针/地址。
我认为您可以从以下内容中获得启发:
$a1=@(1,2,3,4,5)
$b1=@(1,2,3,4,5,6)
$ret = (Compare-Object $a1 $b1).InputObject
if ($ret)
{
"different"
}
else
{
"same"
}
做类似的事情:
$ret = (Compare-Object $actualCollection $expectedCollection).InputObject
$ret | Should Be $null
其中 $null 表示列表是相同的。