Last active
December 20, 2015 23:44
-
-
Save PlagueHO/83cd60cc22ef66cbb52f to your computer and use it in GitHub Desktop.
Example DSC Resource Unit Tests for Set-TargetResource where exists but should not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context 'Virtual Disk exists but should not' { | |
Mock Get-iSCSIVirtualDisk -MockWith { return @($MockVirtualDisk) } | |
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 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment