Assert-Like

Asserts that one string is like another.

Syntax

Assert-Like [[-Haystack] <String>] [[-Needle] <String>] [[-Message] <String>] [<CommonParameters>]

Description

Uses PowerShell's -like operator, so simple wildcards are accepted.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Haystack String

The string to look in.

false false
Needle String

The string to look for.

false false
Message String

The message to use when the assertion fails.

false false

EXAMPLE 1

Assert-Like 'Haystack' '*stack*'

Demonstrates how to assert one string is like another. In this example, the assertion passes, becase 'Haystack' -like '*stack*'.

EXAMPLE 2

Assert-Like 'Haystack' 'needle' 'Couldn''t find the needle in haystack!'

Demonstrates how to show a message when the assertion fails.