Created
March 30, 2017 15:00
-
-
Save cdhunt/018281748ca316803bae67671a69fd72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ArchitestVolumeHaveSizeRemaining([Microsoft.Management.Infrastructure.CimInstance]$ActualValue, $ExpectedValue, [switch] $Negate) | |
{ | |
$ActualValuePropertyValue = $ActualValue | Select-Object -ExpandProperty SizeRemaining | |
[bool] $succeeded = $ActualValuePropertyValue -gt $ExpectedValue | |
if ($Negate) { $succeeded = -not $succeeded } | |
$failureMessage = '' | |
if (-not $succeeded) | |
{ | |
if ($Negate) | |
{ | |
$failureMessage = NotArchitestVolumeHaveSizeRemainingFailureMessage -ActualValue $ActualValuePropertyValue -ExpectedValue $ExpectedValue | |
} | |
else | |
{ | |
$failureMessage = ArchitestVolumeHaveSizeRemainingFailureMessage -ActualValue $ActualValuePropertyValue -ExpectedValue $ExpectedValue | |
} | |
} | |
return New-Object psobject -Property @{ | |
Succeeded = $succeeded | |
FailureMessage = $failureMessage | |
} | |
} | |
function ArchitestVolumeHaveSizeRemaining($ActualValue,$ExpectedValue) | |
{ | |
return "Expected SizeRemaining {$ActualValue} to be greater than {$ExpectedValue}" | |
} | |
function NotArchitestVolumeHaveSizeRemainingFailureMessage($ActualValue,$ExpectedValue) | |
{ | |
return "Expected SizeRemaining {$ActualValue} to be less than or equal to {$ExpectedValue}" | |
} | |
Add-AssertionOperator -Name HaveSizeRemaining ` | |
-Test $function:ArchitestVolumeHaveSizeRemaining ` | |
-Alias 'HSR' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment