Public/Remove-PsFunction.Tests.ps1

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
. "$here\New-PsFunction.ps1"
. "$here\Set-PsModuleBuilderPath.ps1"
. "$here\Get-PsModuleBuilderPath.ps1"

Describe Remove-PsFunction {
  $testPath = "TestDrive:\Modules"
  $testModule = "AwesomeModule"
  $testFunction = "Write-Stuff"
  New-Item $testPath -ItemType Directory -Force | Out-Null
  
  Set-PsModuleBuilderPath $testPath
  $path = Get-PsModuleBuilderPath
  
  New-Item "$path\$testModule\Public" -ItemType Directory -Force | Out-Null
  New-Item "$path\$testModule\Public\$testFunction.ps1" -ItemType File -Force | Out-Null
  New-Item "$path\$testModule\Public\$testFunction.Tests.ps1" -ItemType File -Force | Out-Null
  New-Item "$path\$testModule\Internal" -ItemType Directory -Force | Out-Null
  New-Item "$path\$testModule\Internal\$testFunction.ps1" -ItemType File -Force | Out-Null
  New-Item "$path\$testModule\Internal\$testFunction.Tests.ps1" -ItemType File -Force | Out-Null

  Remove-PsFunction $testModule $testFunction

  It "Should remove the Public/function.ps1 file" {
      Test-Path "$path\$testModule\Public\$testFunction.ps1" -PathType Leaf | Should -Be $false
  }

  It "Should remove the Public/function.Tests.ps1 file" {
      Test-Path "$path\$testModule\Public\$testFunction.Tests.ps1" -PathType Leaf | Should -Be $false
  }
  
  It "Should remove the Internal/function.ps1 file" {
      Test-Path "$path\$testModule\Internal\$testFunction.ps1" -PathType Leaf | Should -Be $false
  }

  It "Should remove the Internal/function.Tests.ps1 file" {
      Test-Path "$path\$testModule\Internal\$testFunction.Tests.ps1" -PathType Leaf | Should -Be $false
  }
}