Port Style Upgrades from xPSDesiredStateConfiguration

This commit is contained in:
Mike Hendrickson
2019-06-03 14:09:27 -07:00
parent 91408140db
commit 3df514c8a4
2 changed files with 4 additions and 56 deletions
@@ -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.
+4 -4
View File
@@ -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'
}