Skip to content

Commit

Permalink
Rename internal Should-* functions to Should-*Assertion to avoid conf…
Browse files Browse the repository at this point in the history
…lict with nnew aliases
  • Loading branch information
nohwnd committed Apr 7, 2024
1 parent 3d1d896 commit b0ffc38
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 67 deletions.
12 changes: 6 additions & 6 deletions src/functions/assertions/Be.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Be
function Should-Be ($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-BeAssertion ($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Compares one object with another for equality
Expand Down Expand Up @@ -64,16 +64,16 @@ function NotShouldBeFailureMessage($ActualValue, $ExpectedValue, $Because) {
}

& $script:SafeCommands['Add-ShouldOperator'] -Name Be `
-InternalName Should-Be `
-Test ${function:Should-Be} `
-InternalName Should-BeAssertion `
-Test ${function:Should-BeAssertion} `
-Alias 'EQ' `
-SupportsArrayInput

Set-ShouldOperatorHelpMessage -OperatorName Be `
-HelpMessage 'Compares one object with another for equality and throws if the two objects are not the same.'

#BeExactly
function Should-BeExactly($ActualValue, $ExpectedValue, $Because) {
function Should-BeAssertionExactly($ActualValue, $ExpectedValue, $Because) {
<#
.SYNOPSIS
Compares one object with another for equality and throws if the
Expand Down Expand Up @@ -137,8 +137,8 @@ function NotShouldBeExactlyFailureMessage($ActualValue, $ExpectedValue, $Because
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeExactly `
-InternalName Should-BeExactly `
-Test ${function:Should-BeExactly} `
-InternalName Should-BeAssertionExactly `
-Test ${function:Should-BeAssertionExactly} `
-Alias 'CEQ' `
-SupportsArrayInput

Expand Down
8 changes: 4 additions & 4 deletions src/functions/assertions/BeGreaterThan.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeGreaterThan($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-BeGreaterThanAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that a number (or other comparable value) is greater than an expected value.
Expand Down Expand Up @@ -43,7 +43,7 @@ function Should-BeLessOrEqual($ActualValue, $ExpectedValue, [switch] $Negate, [s
This test also passes, as PowerShell evaluates `10 -le 10` as true.
#>
if ($Negate) {
return Should-BeGreaterThan -ActualValue $ActualValue -ExpectedValue $ExpectedValue -Negate:$false -Because $Because
return Should-BeGreaterThanAssertion -ActualValue $ActualValue -ExpectedValue $ExpectedValue -Negate:$false -Because $Because
}

if ($ActualValue -gt $ExpectedValue) {
Expand All @@ -59,8 +59,8 @@ function Should-BeLessOrEqual($ActualValue, $ExpectedValue, [switch] $Negate, [s
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeGreaterThan `
-InternalName Should-BeGreaterThan `
-Test ${function:Should-BeGreaterThan} `
-InternalName Should-BeGreaterThanAssertion `
-Test ${function:Should-BeGreaterThanAssertion} `
-Alias 'GT'

Set-ShouldOperatorHelpMessage -OperatorName BeGreaterThan `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/BeIn.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeIn($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-BeInAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that a collection of values contain a specific value.
Expand Down Expand Up @@ -35,8 +35,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeIn `
-InternalName Should-BeIn `
-Test ${function:Should-BeIn}
-InternalName Should-BeInAssertion `
-Test ${function:Should-BeInAssertion}

Set-ShouldOperatorHelpMessage -OperatorName BeIn `
-HelpMessage "Asserts that a collection of values contain a specific value. Uses PowerShell's -contains operator to confirm."
Expand Down
8 changes: 4 additions & 4 deletions src/functions/assertions/BeLessThan.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeLessThan($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-BeLessThanAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that a number (or other comparable value) is lower than an expected value.
Expand Down Expand Up @@ -43,7 +43,7 @@ function Should-BeGreaterOrEqual($ActualValue, $ExpectedValue, [switch] $Negate,
This test also passes, as PowerShell evaluates `2 -ge 2` as true.
#>
if ($Negate) {
return Should-BeLessThan -ActualValue $ActualValue -ExpectedValue $ExpectedValue -Negate:$false -Because $Because
return Should-BeLessThanAssertion -ActualValue $ActualValue -ExpectedValue $ExpectedValue -Negate:$false -Because $Because
}

if ($ActualValue -lt $ExpectedValue) {
Expand All @@ -59,8 +59,8 @@ function Should-BeGreaterOrEqual($ActualValue, $ExpectedValue, [switch] $Negate,
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeLessThan `
-InternalName Should-BeLessThan `
-Test ${function:Should-BeLessThan} `
-InternalName Should-BeLessThanAssertion `
-Test ${function:Should-BeLessThanAssertion} `
-Alias 'LT'

Set-ShouldOperatorHelpMessage -OperatorName BeLessThan `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/BeLike.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeLike($ActualValue, $ExpectedValue, [switch] $Negate, [String] $Because) {
function Should-BeLikeAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [String] $Because) {
<#
.SYNOPSIS
Asserts that the actual value matches a wildcard pattern using PowerShell's -like operator.
Expand Down Expand Up @@ -43,8 +43,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeLike `
-InternalName Should-BeLike `
-Test ${function:Should-BeLike}
-InternalName Should-BeLikeAssertion `
-Test ${function:Should-BeLikeAssertion}

Set-ShouldOperatorHelpMessage -OperatorName BeLike `
-HelpMessage "Asserts that the actual value matches a wildcard pattern using PowerShell's -like operator. This comparison is not case-sensitive."
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/BeLikeExactly.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeLikeExactly($ActualValue, $ExpectedValue, [switch] $Negate, [String] $Because) {
function Should-BeLikeExactlyAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [String] $Because) {
<#
.SYNOPSIS
Asserts that the actual value matches a wildcard pattern using PowerShell's -like operator.
Expand Down Expand Up @@ -42,8 +42,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeLikeExactly `
-InternalName Should-BeLikeExactly `
-Test ${function:Should-BeLikeExactly}
-InternalName Should-BeLikeExactlyAssertion `
-Test ${function:Should-BeLikeExactlyAssertion}

Set-ShouldOperatorHelpMessage -OperatorName BeLikeExactly `
-HelpMessage "Asserts that the actual value matches a wildcard pattern using PowerShell's -like operator. This comparison is case-sensitive."
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/BeNullOrEmpty.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function Should-BeNullOrEmpty($ActualValue, [switch] $Negate, [string] $Because) {
function Should-BeNullOrEmptyAssertion($ActualValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Checks values for null or empty (strings).
Expand Down Expand Up @@ -73,8 +73,8 @@ function NotShouldBeNullOrEmptyFailureMessage ($Because) {
}

& $script:SafeCommands['Add-ShouldOperator'] -Name BeNullOrEmpty `
-InternalName Should-BeNullOrEmpty `
-Test ${function:Should-BeNullOrEmpty} `
-InternalName Should-BeNullOrEmptyAssertion `
-Test ${function:Should-BeNullOrEmptyAssertion} `
-SupportsArrayInput

Set-ShouldOperatorHelpMessage -OperatorName BeNullOrEmpty `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/BeOfType.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function Should-BeOfType($ActualValue, $ExpectedType, [switch] $Negate, [string]$Because) {
function Should-BeOfTypeAssertion($ActualValue, $ExpectedType, [switch] $Negate, [string]$Because) {
<#
.SYNOPSIS
Asserts that the actual value should be an object of a specified type
Expand Down Expand Up @@ -68,8 +68,8 @@ function Should-BeOfType($ActualValue, $ExpectedType, [switch] $Negate, [string]


& $script:SafeCommands['Add-ShouldOperator'] -Name BeOfType `
-InternalName Should-BeOfType `
-Test ${function:Should-BeOfType} `
-InternalName Should-BeOfTypeAssertion `
-Test ${function:Should-BeOfTypeAssertion} `
-Alias 'HaveType'

Set-ShouldOperatorHelpMessage -OperatorName BeOfType `
Expand Down
16 changes: 8 additions & 8 deletions src/functions/assertions/BeTrueOrFalse.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-BeTrue($ActualValue, [switch] $Negate, [string] $Because) {
function Should-BeTrueAssertion($ActualValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that the value is true, or truthy.
Expand All @@ -20,7 +20,7 @@
This test passes as a "truthy" result.
#>
if ($Negate) {
return Should-BeFalse -ActualValue $ActualValue -Negate:$false -Because $Because
return Should-BeFalseAssertion -ActualValue $ActualValue -Negate:$false -Because $Because
}

if (-not $ActualValue) {
Expand All @@ -36,7 +36,7 @@
}
}

function Should-BeFalse($ActualValue, [switch] $Negate, $Because) {
function Should-BeFalseAssertion($ActualValue, [switch] $Negate, $Because) {
<#
.SYNOPSIS
Asserts that the value is false, or falsy.
Expand All @@ -58,7 +58,7 @@ function Should-BeFalse($ActualValue, [switch] $Negate, $Because) {
This test passes as a "falsy" result.
#>
if ($Negate) {
return Should-BeTrue -ActualValue $ActualValue -Negate:$false -Because $Because
return Should-BeTrueAssertion -ActualValue $ActualValue -Negate:$false -Because $Because
}

if ($ActualValue) {
Expand All @@ -76,15 +76,15 @@ function Should-BeFalse($ActualValue, [switch] $Negate, $Because) {


& $script:SafeCommands['Add-ShouldOperator'] -Name BeTrue `
-InternalName Should-BeTrue `
-Test ${function:Should-BeTrue}
-InternalName Should-BeTrueAssertion `
-Test ${function:Should-BeTrueAssertion}

Set-ShouldOperatorHelpMessage -OperatorName BeTrue `
-HelpMessage "Asserts that the value is true, or truthy."

& $script:SafeCommands['Add-ShouldOperator'] -Name BeFalse `
-InternalName Should-BeFalse `
-Test ${function:Should-BeFalse}
-InternalName Should-BeFalseAssertion `
-Test ${function:Should-BeFalseAssertion}

Set-ShouldOperatorHelpMessage -OperatorName BeFalse `
-HelpMessage "Asserts that the value is false, or falsy."
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/Contain.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-Contain($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-ContainAssertion($ActualValue, $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that collection contains a specific value.
Expand Down Expand Up @@ -35,8 +35,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name Contain `
-InternalName Should-Contain `
-Test ${function:Should-Contain} `
-InternalName Should-ContainAssertion `
-Test ${function:Should-ContainAssertion} `
-SupportsArrayInput

Set-ShouldOperatorHelpMessage -OperatorName Contain `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/Exist.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-Exist($ActualValue, [switch] $Negate, [string] $Because) {
function Should-ExistAssertion($ActualValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Does not perform any comparison, but checks if the object calling Exist is present in a PS Provider.
Expand Down Expand Up @@ -36,8 +36,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name Exist `
-InternalName Should-Exist `
-Test ${function:Should-Exist}
-InternalName Should-ExistAssertion `
-Test ${function:Should-ExistAssertion}

Set-ShouldOperatorHelpMessage -OperatorName Exist `
-HelpMessage "Does not perform any comparison, but checks if the object calling Exist is present in a PS Provider. The object must have valid path syntax. It essentially must pass a Test-Path call."
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/FileContentMatch.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-FileContentMatch($ActualValue, $ExpectedContent, [switch] $Negate, $Because) {
function Should-FileContentMatchAssertion($ActualValue, $ExpectedContent, [switch] $Negate, $Because) {
<#
.SYNOPSIS
Checks to see if a file contains the specified text.
Expand Down Expand Up @@ -66,8 +66,8 @@ function NotShouldFileContentMatchFailureMessage($ActualValue, $ExpectedContent,
}

& $script:SafeCommands['Add-ShouldOperator'] -Name FileContentMatch `
-InternalName Should-FileContentMatch `
-Test ${function:Should-FileContentMatch}
-InternalName Should-FileContentMatchAssertion `
-Test ${function:Should-FileContentMatchAssertion}

Set-ShouldOperatorHelpMessage -OperatorName FileContentMatch `
-HelpMessage 'Checks to see if a file contains the specified text. This search is not case sensitive and uses regular expressions.'
6 changes: 3 additions & 3 deletions src/functions/assertions/FileContentMatchMultiline.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-FileContentMatchMultiline($ActualValue, $ExpectedContent, [switch] $Negate, [String] $Because) {
function Should-FileContentMatchMultilineAssertion($ActualValue, $ExpectedContent, [switch] $Negate, [String] $Because) {
<#
.SYNOPSIS
As opposed to FileContentMatch and FileContentMatchExactly operators,
Expand Down Expand Up @@ -58,8 +58,8 @@ function NotShouldFileContentMatchMultilineFailureMessage($ActualValue, $Expecte
}

& $script:SafeCommands['Add-ShouldOperator'] -Name FileContentMatchMultiline `
-InternalName Should-FileContentMatchMultiline `
-Test ${function:Should-FileContentMatchMultiline}
-InternalName Should-FileContentMatchMultilineAssertion `
-Test ${function:Should-FileContentMatchMultilineAssertion}

Set-ShouldOperatorHelpMessage -OperatorName FileContentMatchMultiline `
-HelpMessage 'As opposed to FileContentMatch and FileContentMatchExactly operators, FileContentMatchMultiline presents content of the file being tested as one string object, so that the expression you are comparing it to can consist of several lines.'
6 changes: 3 additions & 3 deletions src/functions/assertions/FileContentMatchMultilineExactly.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-FileContentMatchMultilineExactly($ActualValue, $ExpectedContent, [switch] $Negate, [String] $Because) {
function Should-FileContentMatchMultilineExactlyAssertion($ActualValue, $ExpectedContent, [switch] $Negate, [String] $Because) {
<#
.SYNOPSIS
As opposed to FileContentMatch and FileContentMatchExactly operators,
Expand Down Expand Up @@ -75,8 +75,8 @@ function NotShouldFileContentMatchMultilineExactlyFailureMessage($ActualValue, $
}

& $script:SafeCommands['Add-ShouldOperator'] -Name FileContentMatchMultilineExactly `
-InternalName Should-FileContentMatchMultilineExactly `
-Test ${function:Should-FileContentMatchMultilineExactly}
-InternalName Should-FileContentMatchMultilineExactlyAssertion `
-Test ${function:Should-FileContentMatchMultilineExactlyAssertion}

Set-ShouldOperatorHelpMessage -OperatorName FileContentMatchMultilineExactly `
-HelpMessage 'As opposed to FileContentMatch and FileContentMatchExactly operators, FileContentMatchMultilineExactly presents content of the file being tested as one string object, so that the case sensitive expression you are comparing it to can consist of several lines.'
6 changes: 3 additions & 3 deletions src/functions/assertions/HaveCount.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-HaveCount($ActualValue, [int] $ExpectedValue, [switch] $Negate, [string] $Because) {
function Should-HaveCountAssertion($ActualValue, [int] $ExpectedValue, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Asserts that a collection has the expected amount of items.
Expand Down Expand Up @@ -71,8 +71,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name HaveCount `
-InternalName Should-HaveCount `
-Test ${function:Should-HaveCount} `
-InternalName Should-HaveCountAssertion `
-Test ${function:Should-HaveCountAssertion} `
-SupportsArrayInput

Set-ShouldOperatorHelpMessage -OperatorName HaveCount `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/HaveParameter.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-HaveParameter (
function Should-HaveParameterAssertion (
$ActualValue,
[String] $ParameterName,
$Type,
Expand Down Expand Up @@ -376,8 +376,8 @@
}

& $script:SafeCommands['Add-ShouldOperator'] -Name HaveParameter `
-InternalName Should-HaveParameter `
-Test ${function:Should-HaveParameter}
-InternalName Should-HaveParameterAssertion `
-Test ${function:Should-HaveParameterAssertion}

Set-ShouldOperatorHelpMessage -OperatorName HaveParameter `
-HelpMessage 'Asserts that a command has the expected parameter.'
6 changes: 3 additions & 3 deletions src/functions/assertions/Match.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-Match($ActualValue, $RegularExpression, [switch] $Negate, [string] $Because) {
function Should-MatchAssertion($ActualValue, $RegularExpression, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Uses a regular expression to compare two objects.
Expand Down Expand Up @@ -55,8 +55,8 @@ function NotShouldMatchFailureMessage($ActualValue, $RegularExpression, $Because
}

& $script:SafeCommands['Add-ShouldOperator'] -Name Match `
-InternalName Should-Match `
-Test ${function:Should-Match}
-InternalName Should-MatchAssertion `
-Test ${function:Should-MatchAssertion}

Set-ShouldOperatorHelpMessage -OperatorName Match `
-HelpMessage 'Uses a regular expression to compare two objects. This comparison is not case sensitive.'
6 changes: 3 additions & 3 deletions src/functions/assertions/MatchExactly.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-MatchExactly($ActualValue, $RegularExpression, [switch] $Negate, [string] $Because) {
function Should-MatchExactlyAssertion($ActualValue, $RegularExpression, [switch] $Negate, [string] $Because) {
<#
.SYNOPSIS
Uses a regular expression to compare two objects.
Expand Down Expand Up @@ -48,8 +48,8 @@ function NotShouldMatchExactlyFailureMessage($ActualValue, $RegularExpression) {
}

& $script:SafeCommands['Add-ShouldOperator'] -Name MatchExactly `
-InternalName Should-MatchExactly `
-Test ${function:Should-MatchExactly} `
-InternalName Should-MatchExactlyAssertion `
-Test ${function:Should-MatchExactlyAssertion} `
-Alias 'CMATCH'

Set-ShouldOperatorHelpMessage -OperatorName MatchExactly `
Expand Down
6 changes: 3 additions & 3 deletions src/functions/assertions/PesterThrow.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Should-Throw {
function Should-ThrowAssertion {
<#
.SYNOPSIS
Checks if an exception was thrown. Enclose input in a script block.
Expand Down Expand Up @@ -165,8 +165,8 @@ function NotShouldThrowFailureMessage {
}

& $script:SafeCommands['Add-ShouldOperator'] -Name Throw `
-InternalName Should-Throw `
-Test ${function:Should-Throw}
-InternalName Should-ThrowAssertion `
-Test ${function:Should-ThrowAssertion}

Set-ShouldOperatorHelpMessage -OperatorName Throw `
-HelpMessage 'Checks if an exception was thrown. Enclose input in a scriptblock.'

0 comments on commit b0ffc38

Please sign in to comment.