Skip to content

Commit

Permalink
adding few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
santisq committed Jul 28, 2023
1 parent 2abf053 commit f89010a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/PSTreeDirectory.ps1
Expand Up @@ -7,26 +7,28 @@ Import-Module $manifestPath
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'shared.psm1'))

Describe 'PSTreeDirectory' {
BeforeAll {
$parent = $testPath | Get-PSTree -Depth 0
$parent | Out-Null
}

It 'Can enumerate Files with .EnumerateFiles()' {
$parent.EnumerateFiles() | Should -BeOfType ([System.IO.FileInfo])
($testPath | Get-PSTree -Depth 0).EnumerateFiles() |
ForEach-Object GetType |
Should -Be ([System.IO.FileInfo])
}

It 'Can enumerate Directories with .EnumerateDirectories()' {
$parent.EnumerateDirectories() | Should -BeOfType ([System.IO.DirectoryInfo])
($testPath | Get-PSTree -Depth 0).EnumerateDirectories() |
ForEach-Object GetType |
Should -Be ([System.IO.DirectoryInfo])
}

It 'Can enumerate File System Infos with .EnumerateFileSystemInfos()' {
$parent.EnumerateFileSystemInfos() | ForEach-Object GetType |
($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()' {
$paths = $parent.Parent.FullName.Split([System.IO.Path]::DirectorySeparatorChar)
$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
}
}

0 comments on commit f89010a

Please sign in to comment.