Tests/Touch/Touch.Path.Tests.ps1
|
BeforeAll { . "$PSScriptRoot\..\Shared\Setup.ps1" Initialize-TestEnvironment } AfterAll { Clear-TestEnvironment } Describe 'Touch - Path parameter' { BeforeEach { $script:testFolder = Join-Path $TestDrive "Touch_Path_$(Get-Random)" New-Item -Path $script:testFolder -ItemType Directory -Force | Out-Null } It 'Creates file in absolute path' { Touch 'file.txt' -Path $script:testFolder Test-Path (Join-Path $script:testFolder 'file.txt') | Should -BeTrue } It 'Creates file in current directory when Path is omitted' { $originalLocation = Get-Location try { Set-Location $script:testFolder Touch 'current.txt' Test-Path (Join-Path $script:testFolder 'current.txt') | Should -BeTrue } finally { Set-Location $originalLocation } } It 'Creates multiple files in specified Path with positional args' { Touch 'a.txt' 'b.txt' -Path $script:testFolder 'a.txt', 'b.txt' | ForEach-Object { Test-Path (Join-Path $script:testFolder $_) | Should -BeTrue } } } |