-
Notifications
You must be signed in to change notification settings - Fork 3
/
PSTreeDirectory.ps1
34 lines (28 loc) · 1.35 KB
/
PSTreeDirectory.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$ErrorActionPreference = 'Stop'
$moduleName = (Get-Item ([IO.Path]::Combine($PSScriptRoot, '..', 'module', '*.psd1'))).BaseName
$manifestPath = [IO.Path]::Combine($PSScriptRoot, '..', 'output', $moduleName)
Import-Module $manifestPath
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'shared.psm1'))
Describe 'PSTreeDirectory' {
It 'Can enumerate Files with .EnumerateFiles()' {
($testPath | Get-PSTree -Depth 0).EnumerateFiles() |
ForEach-Object GetType |
Should -Be ([System.IO.FileInfo])
}
It 'Can enumerate Directories with .EnumerateDirectories()' {
($testPath | Get-PSTree -Depth 0).EnumerateDirectories() |
ForEach-Object GetType |
Should -Be ([System.IO.DirectoryInfo])
}
It 'Can enumerate File System Infos with .EnumerateFileSystemInfos()' {
($testPath | Get-PSTree -Depth 0).EnumerateFileSystemInfos() |
ForEach-Object GetType |
Should -BeIn ([System.IO.FileInfo], [System.IO.DirectoryInfo])
}
It 'Can enumerate its parent directories with .GetParents()' {
$parent = ($testPath | Get-PSTree -Depth 0).Parent
$parent | Should -BeOfType ([System.IO.DirectoryInfo])
$paths = $parent.FullName.Split([System.IO.Path]::DirectorySeparatorChar)
$parent.GetParents() | Should -HaveCount $paths.Count
}
}