< Back

Assert-False

Sun Jan 12, 2020 5:38 pm

NAME Assert-False



SYNOPSIS

Asserts an object is false.





SYNTAX

Assert-False [[-InputObject] <Object>] [[-Message] <String>] [<CommonParameters>]





DESCRIPTION

Uses PowerShell's rules for determinig truthiness. The following objects evaluate to `$false`:



* `0`

* `$false`

* '' (i.e. `[String]::Empty`)

* `$null`

* `@()` (i.e. empty arrays)



All other values are true.





PARAMETERS

-InputObject <Object>

The value to check.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

A description about why the assertion might fail.



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-False $true



Demonstrates how to fail a test.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Assert-False (Invoke-SomethingThatShouldFail)



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