@@ -70,6 +70,42 @@ Describe "Test Path" {
7070 }
7171 }
7272
73+ if (! $testingLibraryUsage )
74+ {
75+ # There is probably a more concise way to do this but for now we will settle for this!
76+ Function GetFreeDrive ($freeDriveLen ) {
77+ $ordA = 65
78+ $ordZ = 90
79+ $freeDrive = " "
80+ $freeDriveName = " "
81+ do {
82+ $freeDriveName = (1 .. $freeDriveLen | % {[char ](Get-Random - Maximum $ordZ - Minimum $ordA )}) -join ' '
83+ $freeDrive = $freeDriveName + " :"
84+ }while (Test-Path $freeDrive )
85+ $freeDrive , $freeDriveName
86+ }
87+
88+ Context " When given a glob" {
89+ It " Invokes on all the matching files" {
90+ $numFilesResult = (Invoke-ScriptAnalyzer - Path $directory \Rule* .ps1 | Select-Object - Property ScriptName - Unique).Count
91+ $numFilesExpected = (Get-ChildItem - Path $directory \Rule* .ps1).Count
92+ $numFilesResult | Should be $numFilesExpected
93+ }
94+ }
95+
96+ Context " When given a FileSystem PSDrive" {
97+ It " Recognizes the path" {
98+ $freeDriveNameLen = 2
99+ $freeDrive , $freeDriveName = GetFreeDrive $freeDriveNameLen
100+ New-PSDrive - Name $freeDriveName - PSProvider FileSystem - Root $directory
101+ $numFilesExpected = (Get-ChildItem - Path $freeDrive \R* .ps1).Count
102+ $numFilesResult = (Invoke-ScriptAnalyzer - Path $freeDrive \Rule* .ps1 | Select-Object - Property ScriptName - Unique).Count
103+ Remove-PSDrive $freeDriveName
104+ $numFilesResult | Should Be $numFilesExpected
105+ }
106+ }
107+ }
108+
73109 Context " When given a directory" {
74110 $withoutPathWithDirectory = Invoke-ScriptAnalyzer - Recurse $directory \RecursionDirectoryTest
75111 $withPathWithDirectory = Invoke-ScriptAnalyzer - Recurse - Path $directory \RecursionDirectoryTest
0 commit comments