Skip to content

Commit 55919be

Browse files
committed
Updated Tests for PSProvideDefaultParameterValue
1 parent 4e9732c commit 55919be

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Tests/Rules/ProvideDefaultParameterValue.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
[string]
77
$Param1
88
)
9+
}
10+
11+
function BadFunc2($Param1)
12+
{
913
}

Tests/Rules/ProvideDefaultParameterValue.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Import-Module PSScriptAnalyzer
22
$violationName = "PSProvideDefaultParameterValue"
3-
$violationMessage = "Parameter 'Param1' is not initialized. Non-global variables must be initialized. To fix a violation of this rule, please initialize non-global variables."
3+
$violationMessage = "Parameter 'Param1' is not initialized. Parameters must have a default value. To fix a violation of this rule, please specify a default value for all parameters"
44
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
55
$violations = Invoke-ScriptAnalyzer $directory\ProvideDefaultParameterValue.ps1 | Where-Object {$_.RuleName -match $violationName}
66
$noViolations = Invoke-ScriptAnalyzer $directory\ProvideDefaultParameterValueNoViolations.ps1
77

88
Describe "ProvideDefaultParameters" {
99
Context "When there are violations" {
10-
It "has 1 provide default parameter value violation" {
11-
$violations.Count | Should Be 1
10+
It "has 2 provide default parameter value violation" {
11+
$violations.Count | Should Be 2
1212
}
1313

1414
It "has the correct description message" {

Tests/Rules/ProvideDefaultParameterValueNoViolations.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
$Param1=$null
88
)
99
$Param1
10+
}
11+
12+
function GoodFunc2($Param1 = $null)
13+
{
1014
}

0 commit comments

Comments
 (0)