@@ -70,23 +70,41 @@ Describe "Test Path" {
70
70
}
71
71
}
72
72
73
- Context " When given a glob" {
74
- It " Invokes on all the matching files" {
75
- $numFilesResult = (Invoke-ScriptAnalyzer - Path $directory \Rule* .ps1 | Select-Object - Property ScriptName - Unique).Count
76
- $numFilesExpected = (Get-ChildItem - Path $directory \Rule* .ps1).Count
77
- $numFilesResult | Should be $numFilesExpected
78
- }
79
- }
80
-
81
- Context " When given a FileSystem PSDrive" {
82
- It " Recognizes the path" {
83
- $freeDrive = 69 .. 90 | % {([char ]$_ )+ " :" } | ? {! (Test-Path $_ )} | Select-Object - First 1
84
- New-PSDrive - Name $freeDrive [0 ] - PSProvider FileSystem - Root $directory
85
- $numFilesExpected = (Get-ChildItem - Path $freeDrive \R* .ps1).Count
86
- $numFilesResult = (Invoke-ScriptAnalyzer - Path $freeDrive \Rule* .ps1 | Select-Object - Property ScriptName - Unique).Count
87
- $numFilesResult | Should Be $numFilesExpected
73
+ if (! $testingLibraryUsage )
74
+ {
75
+ # There is probably a more consice 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
+ }
88
107
}
89
- }
90
108
91
109
Context " When given a directory" {
92
110
$withoutPathWithDirectory = Invoke-ScriptAnalyzer - Recurse $directory \RecursionDirectoryTest
0 commit comments