mirror of
https://github.com/PowerShell/PSDscResources
synced 2026-06-21 13:45:29 +00:00
Port Style Upgrades from xPSDesiredStateConfiguration
This commit is contained in:
@@ -1423,58 +1423,6 @@ function Test-RegistryKeyValuesMatch
|
||||
return $registryKeyValuesMatch
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Removes the specified registry key and child subkeys recursively.
|
||||
|
||||
.PARAMETER RegistryKey
|
||||
The registry key to remove.
|
||||
#>
|
||||
function Remove-RegistryKey
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[Microsoft.Win32.RegistryKey]
|
||||
$RegistryKey
|
||||
)
|
||||
|
||||
$parentKeyName = Split-Path -Path $RegistryKey.Name -Parent
|
||||
$targetKeyName = Split-Path -Path $RegistryKey.Name -Leaf
|
||||
|
||||
$parentRegistryKey = Get-RegistryKey -RegistryKeyPath $parentKeyName -WriteAccessAllowed
|
||||
|
||||
$null = $parentRegistryKey.DeleteSubKeyTree($targetKeyName)
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Removes the specified value of the specified registry key.
|
||||
This is a wrapper function for unit testing.
|
||||
|
||||
.PARAMETER RegistryKey
|
||||
The registry key to remove the default value of.
|
||||
#>
|
||||
function Remove-RegistryKeyValue
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[Microsoft.Win32.RegistryKey]
|
||||
$RegistryKey,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[AllowEmptyString()]
|
||||
[System.String]
|
||||
$RegistryKeyValueName
|
||||
)
|
||||
|
||||
$null = $RegistryKey.DeleteValue($RegistryKeyValueName)
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Removes the default value of the specified registry key.
|
||||
|
||||
@@ -119,7 +119,7 @@ Describe 'GroupResource Unit Tests' {
|
||||
}
|
||||
|
||||
<#
|
||||
Get-Group, Add-GroupMember, Remove-GroupMember, Clear-GroupMembers, Save-Group,
|
||||
Get-Group, Add-GroupMember, Remove-GroupMember, Clear-GroupMember, Save-Group,
|
||||
Remove-Group, Find-Principal, and Remove-DisposableObject cannot be unit tested
|
||||
because they are wrapper functions for .NET class function calls.
|
||||
#>
|
||||
@@ -1225,7 +1225,7 @@ Describe 'GroupResource Unit Tests' {
|
||||
(
|
||||
)
|
||||
|
||||
Assert-MockCalled -CommandName 'Clear-GroupMembers' -Times 0 -Scope 'It'
|
||||
Assert-MockCalled -CommandName 'Clear-GroupMember' -Times 0 -Scope 'It'
|
||||
Assert-MockCalled -CommandName 'Add-GroupMember' -Times 0 -Scope 'It'
|
||||
Assert-MockCalled -CommandName 'Remove-GroupMember' -Times 0 -Scope 'It'
|
||||
Assert-MockCalled -CommandName 'Save-Group' -Times 0 -Scope 'It'
|
||||
@@ -1258,7 +1258,7 @@ Describe 'GroupResource Unit Tests' {
|
||||
return $memberPrincipals
|
||||
}
|
||||
|
||||
Mock -CommandName 'Clear-GroupMembers' -MockWith { }
|
||||
Mock -CommandName 'Clear-GroupMember' -MockWith { }
|
||||
Mock -CommandName 'Add-GroupMember' -MockWith { }
|
||||
Mock -CommandName 'Remove-GroupMember' -MockWith { }
|
||||
Mock -CommandName 'Remove-Group' -MockWith { }
|
||||
@@ -1495,7 +1495,7 @@ Describe 'GroupResource Unit Tests' {
|
||||
Assert-MockCalled -CommandName 'Get-PrincipalContext'
|
||||
Assert-MockCalled -CommandName 'Get-Group' -ParameterFilter { $GroupName -eq $script:testGroupName }
|
||||
Assert-MockCalled -CommandName 'Get-MembersAsPrincipalsList' -ParameterFilter { $Group.Name -eq $script:testGroupName }
|
||||
Assert-MockCalled -CommandName 'Clear-GroupMembers' -ParameterFilter { $Group.Name -eq $script:testGroupName }
|
||||
Assert-MockCalled -CommandName 'Clear-GroupMember' -ParameterFilter { $Group.Name -eq $script:testGroupName }
|
||||
Assert-MockCalled -CommandName 'Save-Group' -ParameterFilter { $Group.Name -eq $script:testGroupName }
|
||||
Assert-MockCalled -CommandName 'Remove-DisposableObject'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user