Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

Commit 8f48d80

Browse files
committed
0.1.5
QA: - Added tests for remove-from-registry
1 parent c40cdb5 commit 8f48d80

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Describe 'Remove-RegistryValue' {
2+
BeforeAll {
3+
. $PSScriptRoot/../src/remove-from-registry.ps1
4+
5+
Mock Write-Host {
6+
param($Object)
7+
$global:actualParameters = $Object
8+
}
9+
}
10+
11+
BeforeEach {
12+
if (-Not (Test-Path -Path "TestRegistry:\TestLocation"))
13+
{
14+
New-Item -Path TestRegistry:\ -Name TestLocation
15+
}
16+
New-ItemProperty -Path "TestRegistry:\TestLocation" -Name "TestKey" -Value "sample"
17+
18+
Test-Path -Path "TestRegistry:\TestLocation" | Should -Be $true
19+
$value = Get-ItemProperty -Path "TestRegistry:\TestLocation" -Name "TestKey" | Select-Object -ExpandProperty "TestKey"
20+
$value | Should -Be "sample"
21+
}
22+
23+
It 'Should delete registry key' {
24+
$result = Remove-RegistryValue -registryValue "TestRegistry:\TestLocation\TestKey"
25+
$result | Should -Be $true
26+
27+
Test-Path -Path "TestRegistry:\TestLocation" | Should -Be $true
28+
$result = $null -eq (Get-ItemProperty -Path "TestRegistry:\TestLocation" -Name "TestKey" -ErrorAction SilentlyContinue)
29+
$result | Should -Be $true
30+
Should -Invoke Write-Host -Exactly 1
31+
Should -Invoke Write-Host -Exactly 1 -ParameterFilter { $Object -eq "Removed: TestRegistry:\TestLocation\TestKey" }
32+
}
33+
}

0 commit comments

Comments
 (0)