Skip to content

Commit a340bfa

Browse files
author
Kapil Borle
committed
Add end-to-end test when CustomRulePath is in settings file
1 parent b597b82 commit a340bfa

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,45 @@ Describe "Test CustomizedRulePath" {
380380
$customizedRulePath = Invoke-ScriptAnalyzer $directory\TestScript.ps1 -CustomRulePath ("$directory\CommunityAnalyzerRules", "$directory\samplerule", "$directory\samplerule\samplerule2")
381381
$customizedRulePath.Count | Should Be 3
382382
}
383-
384383
}
385384

385+
if (!$testingLibraryUsage)
386+
{
387+
Context "When used from settings file" {
388+
It "Should use the CustomRulePath parameter" {
389+
$settings = @{
390+
CustomRulePath = "$directory\CommunityAnalyzerRules"
391+
IncludeDefaultRules = $false
392+
RecurseCustomRulePath = $false
393+
}
394+
395+
$v = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 -Settings $settings
396+
$v.Count | Should Be 1
397+
}
398+
399+
It "Should use the IncludeDefaultRulePath parameter" {
400+
$settings = @{
401+
CustomRulePath = "$directory\CommunityAnalyzerRules"
402+
IncludeDefaultRules = $true
403+
RecurseCustomRulePath = $false
404+
}
405+
406+
$v = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 -Settings $settings
407+
$v.Count | Should Be 2
408+
}
409+
410+
It "Should use the RecurseCustomRulePath parameter" {
411+
$settings = @{
412+
CustomRulePath = "$directory\samplerule"
413+
IncludeDefaultRules = $false
414+
RecurseCustomRulePath = $true
415+
}
416+
417+
$v = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1 -Settings $settings
418+
$v.Count | Should Be 3
419+
}
420+
}
421+
}
386422

387423
Context "When used incorrectly" {
388424
It "file cannot be found" {

0 commit comments

Comments
 (0)