PSCustomObject
sの配列に、値と一致するTitle
プロパティを持つアイテムが含まれているかどうかを判断する必要があります。 Pester アサーションで使用するブール値が必要です:
$Items -<function> $Name | Should Be $True
仮定:
$Items = @()
$Items += [PsCustomObject]@{Title='foo';Url='http://f.io'}
$Items += [PsCustomObject]@{Title='bar';Url='http://b.io'}
Contains
が機能しない:
PS> $Items -contains 'foo'
False
Match
は一致するインスタンスを返しますが、ブール値ではありません:
PS> $Items -match 'foo'
Title Url
----- ---
foo http://f.io
私はできると思います:
($Items -Match $Name).Count | Should Be 1
より良いオプションはありますか?
使用する:
$Items.Title -contains 'foo'