özellik değerine sahip bir örnek içerdiğini belirleyin. PsCustomObject
s dizisinin Başlık özelliğine sahip bir öğeyle eşleşen bir öğe içerip içermediğini belirlemeliyim.PsCustomObjects dizisinin
$Items -<function> $Name | Should Be $True
varsayarsak:
[email protected]()
$Items+=[PsCustomObject]@{Title='foo';Url='http://f.io'}
$Items+=[PsCustomObject]@{Title='bar';Url='http://b.io'}
Contains
çalışmaz:
PS> $Items -contains 'foo'
False
Match
döner eşleştirme örneği, ancak bir Boole bir Boole Pester iddialar ile kullanım için değer gerekir:
PS> $Items -match 'foo'
Title Url
----- ---
foo http://f.io
Elimden varsayalım:
($Items -Match $Name).Count | Should Be 1
daha iyi bir seçenek var mı? sözlerinden
'$ Items.Title -Var 'foo'' – PetSerAl
Ugh. Tabii ki * bu * basit ... – craig
@craig maç için: '[bool] ($ Items-eşleşmesi 'foo')' –