Tests/Environment/Remove-EnvironmentVariable.Tests.ps1
|
BeforeAll { Set-StrictMode -Version "Latest" . "$PSScriptRoot\..\..\Source\Environment\Remove-EnvironmentVariable.ps1" } Describe "Remove-EnvironmentVariable" { It "Removes a Process-scoped variable" { [Environment]::SetEnvironmentVariable("ToolboxTestVariable", "ToolboxTestValue", "Process") Remove-EnvironmentVariable -Name "ToolboxTestVariable" -Scope "Process" [Environment]::GetEnvironmentVariable("ToolboxTestVariable", "Process") | Should -BeNullOrEmpty } It "Does nothing under -WhatIf" { [Environment]::SetEnvironmentVariable("ToolboxTestVariable", "ToolboxTestValue", "Process") Remove-EnvironmentVariable -Name "ToolboxTestVariable" -Scope "Process" -WhatIf [Environment]::GetEnvironmentVariable("ToolboxTestVariable", "Process") | Should -Be "ToolboxTestValue" [Environment]::SetEnvironmentVariable("ToolboxTestVariable", $null, "Process") } It "Accepts the variable name from the pipeline" { [Environment]::SetEnvironmentVariable("ToolboxTestVariable", "ToolboxTestValue", "Process") "ToolboxTestVariable" | Remove-EnvironmentVariable -Scope "Process" [Environment]::GetEnvironmentVariable("ToolboxTestVariable", "Process") | Should -BeNullOrEmpty } } |