Skip to content

Commit

Permalink
Added tests for new helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Apr 26, 2019
1 parent 556142b commit c4ccb0d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ Export-ModuleMember -Function @(
'New-InvalidArgumentException',
'New-InvalidOperationException',
'New-ObjectNotFoundException',
'New-InvalidResultException'
'New-InvalidResultException',
'New-NotImplementedException'
'Get-LocalizedData'
)
24 changes: 24 additions & 0 deletions Tests/Unit/DscResource.LocalizationHelper.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,30 @@ InModuleScope 'DscResource.LocalizationHelper' {
Assert-VerifiableMock
}

Describe 'DscResource.LocalizationHelper\New-NotImplementedException' {
Context 'When calling with Message parameter only' {
It 'Should throw the correct error' {
$mockErrorMessage = 'Mocked error'

{ New-NotImplementedException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage
}
}

Context 'When calling with both the Message and ErrorRecord parameter' {
It 'Should throw the correct error' {
$mockErrorMessage = 'Mocked error'
$mockExceptionErrorMessage = 'Mocked exception error message'

$mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage
$mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null

{ New-NotImplementedException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.NotImplementedException: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage)
}
}

Assert-VerifiableMock
}

Describe 'DscResource.LocalizationHelper\New-InvalidArgumentException' {
Context 'When calling with both the Message and ArgumentName parameter' {
It 'Should throw the correct error' {
Expand Down

0 comments on commit c4ccb0d

Please sign in to comment.