Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows")
$testKey2 = "TestKey2"
$testPropertyName = "TestEntry"
$testPropertyValue = 1
$defaultPropertyName = "(Default)"
$defaultPropertyValue = "something"
$otherPropertyValue = "other"
}
}

Expand Down Expand Up @@ -44,6 +47,34 @@ Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows")
}

Context "Validate basic registry provider Cmdlets" {
It "Verify Test-Path" {
Test-Path -IsValid Registry::HKCU/Software | Should Be $true
Test-Path -IsValid Registry::foo/Softare | Should Be $false
}

It "Verify Get-Item" {
$item = Get-Item $testKey
$item.PSChildName | Should BeExactly $testKey
}

It "Verify Get-Item on inaccessible path" {
{ Get-Item HKLM:\SAM\SAM -ErrorAction Stop } | ShouldBeErrorId "System.Security.SecurityException,Microsoft.PowerShell.Commands.GetItemCommand"
}

It "Verify Get-ChildItem" {
$items = Get-ChildItem
$items.Count | Should BeExactly 2
$Items.PSChildName -contains $testKey | Should Be $true
$Items.PSChildName -contains $testKey2 | Should Be $true
}

It "Verify Get-ChildItem can get subkey names" {
$items = Get-ChildItem -Name
$items.Count | Should BeExactly 2
$items -contains $testKey | Should Be $true
$items -contains $testKey2 | Should Be $true
}

It "Verify New-Item" {
$newKey = New-Item -Path "NewItemTest"
Test-Path "NewItemTest" | Should Be $true
Expand Down Expand Up @@ -87,6 +118,19 @@ Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows")
$property."$testPropertyName" | Should Be 2
}

It "Verify Set-Item" {
Set-Item -Path $testKey -Value $defaultPropertyValue
$property = Get-ItemProperty -Path $testKey -Name $defaultPropertyName
$property."$defaultPropertyName" | Should BeExactly $defaultPropertyValue
}

It "Verify Set-Item with -WhatIf" {
Set-Item -Path $testKey -Value $defaultPropertyValue
Set-Item -Path $testKey -Value $otherPropertyValue -WhatIf
$property = Get-ItemProperty -Path $testKey -Name $defaultPropertyName
$property."$defaultPropertyName" | Should BeExactly $defaultPropertyValue
}

It "Verify Get-ItemPropertyValue" {
$propertyValue = Get-ItemPropertyValue -Path $testKey -Name $testPropertyName
$propertyValue | Should Be $testPropertyValue
Expand Down Expand Up @@ -125,6 +169,22 @@ Describe "Basic Registry Provider Tests" -Tags @("CI", "RequireAdminOnWindows")
$property."$testPropertyName" | Should Be 0
}

It "Verify Clear-Item" {
Set-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue
Set-Item -Path $testKey -Value $defaultPropertyValue
Clear-Item -Path $testKey
$key = Get-Item -Path $testKey
$key.Property.Length | Should BeExactly 0
}

It "Verify Clear-Item with -WhatIf" {
Set-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue
Set-Item -Path $testKey -Value $defaultPropertyValue
Clear-Item -Path $testKey -WhatIf
$key = Get-Item -Path $testKey
$key.Property.Length | Should BeExactly 2
}

It "Verify Remove-ItemProperty" {
Remove-ItemProperty -Path $testKey -Name $testPropertyName
$properties = @(Get-ItemProperty -Path $testKey)
Expand Down