< Back
Assert-Contains
Post
NAME Assert-Contains
SYNOPSIS
Asserts that a collection contains an object/item.
SYNTAX
Assert-Contains [[-Haystack] <Object>] [[-Needle] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
Use's PowerShell's `-contains` operator to check if a collection contains an object/item.
PARAMETERS
-Haystack <Object>
The collection to check.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Needle <Object>
The object to check the collection for.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
A message to show when the assertion fails.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Assert-Contains @( 1, 2, 3 ) 3
Demonstrates how to assert a collection contains an item.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-Contain @( 1, 2 ) 3 'Three is the loneliest number.'
Demonstrates how to show your own message if the assertion fails.
RELATED LINKS
SYNOPSIS
Asserts that a collection contains an object/item.
SYNTAX
Assert-Contains [[-Haystack] <Object>] [[-Needle] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
Use's PowerShell's `-contains` operator to check if a collection contains an object/item.
PARAMETERS
-Haystack <Object>
The collection to check.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Needle <Object>
The object to check the collection for.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
A message to show when the assertion fails.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Assert-Contains @( 1, 2, 3 ) 3
Demonstrates how to assert a collection contains an item.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-Contain @( 1, 2 ) 3 'Three is the loneliest number.'
Demonstrates how to show your own message if the assertion fails.
RELATED LINKS