Skip to content

Commit

Permalink
Update xGroupResource
Browse files Browse the repository at this point in the history
- Updates to resolve the reported PSSA issues
- Formatting updated as per style guidelines
- Comment-based help added to Get-/Set-/Test-TargetResource functions
- Typos fixed in Unit test script
- Unit test 'Get-TargetResource/Should return hashtable with correct values when group has no members' updated to handle the expected empty Members array correctly

Fixes dsccommunity#130
  • Loading branch information
Dan1el42 committed Sep 17, 2016
1 parent 88165e0 commit 3258ead
Show file tree
Hide file tree
Showing 5 changed files with 1,303 additions and 532 deletions.
29 changes: 20 additions & 9 deletions DSCResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ function New-InvalidArgumentException
$ArgumentName
)

$argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message, $ArgumentName )
$errorRecord = New-Object -TypeName 'System.Management.Automation.ErrorRecord' -ArgumentList @( $argumentException, $ArgumentName, 'InvalidArgument', $null)
$argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message,
$ArgumentName )
$newObjectParams = @{
TypeName = 'System.Management.Automation.ErrorRecord'
ArgumentList = @( $argumentException, $ArgumentName, 'InvalidArgument', $null )
}
$errorRecord = New-Object @newObjectParams

throw $errorRecord
}
Expand Down Expand Up @@ -73,18 +78,24 @@ function New-InvalidOperationException
}
elseif ($null -eq $ErrorRecord)
{
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message )
$invalidOperationException =
New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message )
}
else
{
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, $ErrorRecord.Exception)
$invalidOperationException =
New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message,
$ErrorRecord.Exception )
}

$errorRecordToThrow = New-Object -TypeName 'System.Management.Automation.ErrorRecord' -ArgumentList @( $invalidOperationException.ToString(), 'MachineStateIncorrect', 'InvalidOperation' ,$null)
$newObjectParams = @{
TypeName = 'System.Management.Automation.ErrorRecord'
ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect',
'InvalidOperation', $null )
}
$errorRecordToThrow = New-Object @newObjectParams
throw $errorRecordToThrow
}

Export-ModuleMember -Function `
Test-IsNanoServer, `
New-InvalidArgumentException, `
New-InvalidOperationException
Export-ModuleMember -Function @( 'Test-IsNanoServer', 'New-InvalidArgumentException',
'New-InvalidOperationException' )
Loading

0 comments on commit 3258ead

Please sign in to comment.