File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,23 @@ Describe "Test Path" {
124124 }
125125 }
126126
127+ Context " DiagnosticRecord " {
128+ It " has valid ScriptPath and ScriptName properties when an input file is given" {
129+ $scriptName = " TestScript.ps1"
130+ $scriptPath = Join-Path $directory $scriptName
131+ $expectedScriptPath = Resolve-Path $directory \TestScript.ps1
132+ $diagnosticRecords = Invoke-ScriptAnalyzer $scriptPath - IncludeRule " PSAvoidUsingEmptyCatchBlock"
133+ $diagnosticRecords [0 ].ScriptPath | Should Be $expectedScriptPath.Path
134+ $diagnosticRecords [0 ].ScriptName | Should Be $scriptName
135+ }
136+
137+ It " has empty ScriptPath and ScriptName properties when a script definition is given" {
138+ $diagnosticRecords = Invoke-ScriptAnalyzer - ScriptDefinition gci - IncludeRule " PSAvoidUsingCmdletAliases"
139+ $diagnosticRecords [0 ].ScriptPath | Should Be ([System.String ]::Empty)
140+ $diagnosticRecords [0 ].ScriptName | Should Be ([System.String ]::Empty)
141+ }
142+ }
143+
127144 if (! $testingLibraryUsage )
128145 {
129146 # There is probably a more concise way to do this but for now we will settle for this!
@@ -177,7 +194,6 @@ Describe "Test Path" {
177194 Write-Output $writeHostViolation.Count
178195 $globalVarsViolation.Count -eq 1 -and $writeHostViolation.Count -eq 1 | Should Be $true
179196 }
180-
181197 }
182198}
183199
You can’t perform that action at this time.
0 commit comments