Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Assert #318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/public/Assert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function Assert {
.DESCRIPTION
This is a helper function that makes the code less noisy by eliminating many of the "if" statements that are normally required to verify assumptions in the code.

.PARAMETER conditionToCheck
.PARAMETER ConditionToCheck
The boolean condition to evaluate

.PARAMETER failureMessage
The error message used for the exception if the conditionToCheck parameter is false
.PARAMETER FailureMessage
The error message used for the exception if the ConditionToCheck parameter is false

.EXAMPLE
C:\PS>Assert $false "This always throws an exception"
Expand All @@ -24,7 +24,7 @@ function Assert {

Note:
It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition
so that a boolean value is calculated and passed into the 'conditionToCheck' parameter.
so that a boolean value is calculated and passed into the 'ConditionToCheck' parameter.

Example:
Assert 1 -eq 2 "1 doesn't equal 2"
Expand Down Expand Up @@ -59,13 +59,13 @@ function Assert {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
$conditionToCheck,
$ConditionToCheck,

[Parameter(Mandatory = $true)]
[string]$failureMessage
[string]$FailureMessage
)

if (-not $conditionToCheck) {
throw ('Assert: {0}' -f $failureMessage)
if (-not $ConditionToCheck) {
throw ('Assert: {0}' -f $FailureMessage)
}
}