Skip to content

Commit 4f73aa8

Browse files
author
Kapil Borle
committed
Add tests for updated logic
1 parent bc2ebef commit 4f73aa8

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
Import-Module PSScriptAnalyzer
22
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
33
$ruleName = 'PSDSCUseIdenticalMandatoryParametersForDSC'
4-
$resourceFilepath = [System.IO.Path]::Combine(
5-
$directory,
6-
'DSCResourceModule',
7-
'DSCResources',
4+
$resourceBasepath = "$directory\DSCResourceModule\DSCResources"
5+
$badResourceFilepath = [System.IO.Path]::Combine(
6+
$resourceBasepath,
87
'MSFT_WaitForAnyNoIdenticalMandatoryParameter',
98
'MSFT_WaitForAnyNoIdenticalMandatoryParameter.psm1');
9+
$goodResourceFilepath = [System.IO.Path]::Combine($resourceBasepath,'MSFT_WaitForAny','MSFT_WaitForAny.psm1');
10+
1011

1112
Describe "UseIdenticalMandatoryParametersForDSC" {
12-
Context "When a mandatory parameter is not present" {
13+
Context "When a mandatory parameters are not present" {
1314
BeforeAll {
14-
$violations = Invoke-ScriptAnalyzer -Path $resourceFilepath -IncludeRule $ruleName
15+
$violations = Invoke-ScriptAnalyzer -Path $badResourceFilepath -IncludeRule $ruleName
1516
}
1617

17-
# todo add a test to check one violation per function
1818
It "Should find a violations" {
19-
$violations.Count | Should Be 1
19+
$violations.Count | Should Be 4
2020
}
2121

2222
It "Should mark only the function name" {
2323
$violations[0].Extent.Text | Should Be 'Get-TargetResource'
2424
}
2525
}
26+
27+
Context "When all mandatory parameters are present" {
28+
BeforeAll {
29+
$violations = Invoke-ScriptAnalyzer -Path $goodResourceFilepath -IncludeRule $ruleName
30+
}
31+
32+
# todo add a test to check one violation per function
33+
It "Should find a violations" {
34+
$violations.Count | Should Be 0
35+
}
36+
}
2637
}

0 commit comments

Comments
 (0)