From f89010ad6fe27153aa3205270d9344b12a2b70bc Mon Sep 17 00:00:00 2001 From: Santiago Squarzon Date: Fri, 28 Jul 2023 19:34:02 -0300 Subject: [PATCH] adding few more tests --- tests/PSTreeDirectory.ps1 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/PSTreeDirectory.ps1 b/tests/PSTreeDirectory.ps1 index 9f146b8..8c7644f 100644 --- a/tests/PSTreeDirectory.ps1 +++ b/tests/PSTreeDirectory.ps1 @@ -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 } }