Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Last active February 28, 2017 14:48
Show Gist options
  • Save nohwnd/52c121c9a067bc26791b2c9065aebfaf to your computer and use it in GitHub Desktop.
Save nohwnd/52c121c9a067bc26791b2c9065aebfaf to your computer and use it in GitHub Desktop.
Should Be NullOrEmpty
We are comparing if two values are equal so
when $Expected is string with value 'NullOrEmpty'
and $Actual is $null then the result is:
False
We are comparing if two values are equal so
when $Expected is string with value 'NullOrEmpty'
and Actual is string with value 'NullOrEmpty' then the result is:
True
function Should-Be {
param($Expected,[Parameter(ValueFromPipeline)]$Actual)
"We are comparing if two values are equal so"
"when `$Expected is $($Expected.GetType()) with value '$Expected'"
if ($null -eq $Actual)
{
"and `$Actual is `$null then the result is:"
}
else
{
"and Actual is $($Actual.GetType()) with value '$Actual' then the result is:"
}
$Expected -Eq $Actual
"`n"
}
$null | Should-Be NullOrEmpty
"NullOrEmpty" | Should-Be NullOrEmpty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment