< Back
Assert-True
Post
NAME Assert-True
SYNOPSIS
Asserts a condition is true.
SYNTAX
Assert-True [[-Condition] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
Uses PowerShell's rules for determinig truthiness. All values are true except:
* `0`
* `$false`
* '' (i.e. `[String]::Empty`)
* `$null`
* `@()` (i.e. empty arrays)
All other values are true.
PARAMETERS
-Condition <Object>
The object/value to test for truthiness.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
A message to show if `Condition` isn't `$true`.
Required? false
Position? 2
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-True $false
Demonstrates how to fail a test.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-True (Invoke-SomethingThatShouldReturnSomething)
Demonstrates how to check that a function returns a true object/value.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Assert-False $true 'The fladoozle didn't dooflaple.'
Demonstrates how to use the `Message` parameter to describe why the assertion might have failed.
RELATED LINKS
SYNOPSIS
Asserts a condition is true.
SYNTAX
Assert-True [[-Condition] <Object>] [[-Message] <String>] [<CommonParameters>]
DESCRIPTION
Uses PowerShell's rules for determinig truthiness. All values are true except:
* `0`
* `$false`
* '' (i.e. `[String]::Empty`)
* `$null`
* `@()` (i.e. empty arrays)
All other values are true.
PARAMETERS
-Condition <Object>
The object/value to test for truthiness.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <String>
A message to show if `Condition` isn't `$true`.
Required? false
Position? 2
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-True $false
Demonstrates how to fail a test.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Assert-True (Invoke-SomethingThatShouldReturnSomething)
Demonstrates how to check that a function returns a true object/value.
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Assert-False $true 'The fladoozle didn't dooflaple.'
Demonstrates how to use the `Message` parameter to describe why the assertion might have failed.
RELATED LINKS