Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlagueHO/6b3e30de7326e908ad1e to your computer and use it in GitHub Desktop.
Save PlagueHO/6b3e30de7326e908ad1e to your computer and use it in GitHub Desktop.
Example DSC Resource Unit Tests for Set-TargetResource where does not exists and should not
Context 'Virtual Disk does not exist and should not' {
Mock Get-iSCSIVirtualDisk
Mock New-iSCSIVirtualDisk
Mock Set-iSCSIVirtualDisk
Mock Remove-iSCSIVirtualDisk
It 'should not throw error' {
{
$Splat = $TestVirtualDisk.Clone()
$Splat.Ensure = 'Absent'
Set-TargetResource @Splat
} | Should Not Throw
}
It 'should call expected Mocks' {
Assert-MockCalled -commandName Get-iSCSIVirtualDisk -Exactly 1
Assert-MockCalled -commandName New-iSCSIVirtualDisk -Exactly 0
Assert-MockCalled -commandName Set-iSCSIVirtualDisk -Exactly 0
Assert-MockCalled -commandName Remove-iSCSIVirtualDisk -Exactly 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment