Created
December 23, 2015 05:49
-
-
Save PlagueHO/593cdfc77c63d5fe19b4 to your computer and use it in GitHub Desktop.
Example DSC Unit Tests for Get-VirtualDisk function
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
Describe "$($Global:DSCResourceName)\Get-VirtualDisk" { | |
Context 'Virtual Disk does not exist' { | |
Mock Get-iSCSIVirtualDisk | |
It 'should return null' { | |
$Splat = $TestVirtualDisk.Clone() | |
$Result = Get-VirtualDisk -Path $Splat.Path | |
$Result | Should Be $null | |
} | |
It 'should call expected Mocks' { | |
Assert-MockCalled -commandName Get-iSCSIVirtualDisk -Exactly 1 | |
} | |
} | |
Context 'Virtual Disk does exist' { | |
Mock Get-iSCSIVirtualDisk -MockWith { return @($MockVirtualDisk) } | |
It 'should return expected parameters' { | |
$Splat = $TestVirtualDisk.Clone() | |
$Result = Get-VirtualDisk -Path $Splat.Path | |
$Result.Path | Should Be $MockVirtualDisk.Path | |
$Result.DiskType | Should Be $MockVirtualDisk.DiskType | |
$Result.Size | Should Be $MockVirtualDisk.Size | |
$Result.Description | Should Be $MockVirtualDisk.Description | |
$Result.ParentPath | Should Be $MockVirtualDisk.ParentPath | |
} | |
It 'should call expected Mocks' { | |
Assert-MockCalled -commandName Get-iSCSIVirtualDisk -Exactly 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment