Tests/Touch/Touch.Creation.Tests.ps1
|
BeforeAll { . "$PSScriptRoot\..\Shared\Setup.ps1" Initialize-TestEnvironment } AfterAll { Clear-TestEnvironment } Describe 'Touch - Basic file creation' { BeforeEach { $script:testFolder = Join-Path $TestDrive "Touch_Creation_$(Get-Random)" New-Item -Path $script:testFolder -ItemType Directory -Force | Out-Null } It 'Creates a single file with -Name' { Touch -Name 'hello.txt' -Path $script:testFolder Test-Path (Join-Path $script:testFolder 'hello.txt') | Should -BeTrue } It 'Creates a single file using positional parameter' { Touch 'index.html' -Path $script:testFolder Test-Path (Join-Path $script:testFolder 'index.html') | Should -BeTrue } It 'Creates multiple files from -Name array' { Touch -Name 'a.txt', 'b.txt', 'c.txt' -Path $script:testFolder 'a.txt', 'b.txt', 'c.txt' | ForEach-Object { Test-Path (Join-Path $script:testFolder $_) | Should -BeTrue } } It 'Creates multiple files using positional parameters (remaining args)' { Touch 'index.html' 'style.css' 'app.js' -Path $script:testFolder 'index.html', 'style.css', 'app.js' | ForEach-Object { Test-Path (Join-Path $script:testFolder $_) | Should -BeTrue } } It 'Creates a single file via pipeline' { 'pipe.txt' | Touch -Path $script:testFolder Test-Path (Join-Path $script:testFolder 'pipe.txt') | Should -BeTrue } It 'Creates multiple files via pipeline' { 'pipe1.txt', 'pipe2.txt', 'pipe3.txt' | Touch -Path $script:testFolder 'pipe1.txt', 'pipe2.txt', 'pipe3.txt' | ForEach-Object { Test-Path (Join-Path $script:testFolder $_) | Should -BeTrue } } } |