Skip to content

Commit 9af76ec

Browse files
author
Kapil Borle
committed
Add test to verify whitelist in UseSingularNoun rule
1 parent 9d53d8d commit 9af76ec

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Tests/Rules/UseSingularNounsReservedVerbs.tests.ps1

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ Describe "UseSingularNouns" {
2121
$nounViolations[0].Message | Should Match $nounViolationMessage
2222
}
2323

24-
It "has the correct extent" {
25-
$nounViolations[0].Extent.Text | Should be "Verb-Files"
26-
}
27-
28-
It "excludes items from noun whitelist" {
29-
$nounViolationScript = @'
30-
Function Add-SomeData
31-
{
32-
Write-Output "Adding some data"
24+
It "has the correct extent" {
25+
$nounViolations[0].Extent.Text | Should be "Verb-Files"
3326
}
34-
'@
35-
Invoke-ScriptAnalyzer -ScriptDefinition $nounViolationScript `
36-
-IncludeRule "PSUseSingularNouns" `
37-
-OutVariable violations
38-
$violations.Count | Should Be 0
3927
}
28+
29+
Context "When function names have nouns from whitelist" {
30+
31+
It "ignores function name ending with Data" {
32+
$nounViolationScript = @'
33+
Function Add-SomeData
34+
{
35+
Write-Output "Adding some data"
36+
}
37+
'@
38+
Invoke-ScriptAnalyzer -ScriptDefinition $nounViolationScript `
39+
-IncludeRule "PSUseSingularNouns" `
40+
-OutVariable violations
41+
$violations.Count | Should Be 0
42+
}
4043
}
4144

4245
Context "When there are no violations" {

0 commit comments

Comments
 (0)