Created
December 17, 2015 21:37
-
-
Save PlagueHO/07f0914ce00ae8a963df to your computer and use it in GitHub Desktop.
A Unit test of the xFirewall DSC Resource in the xNetworking module
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 'MSFT_xFirewall\Get-TargetResource' { | |
Context 'Absent should return correctly' { | |
Mock Get-NetFirewallRule | |
It "Should return absent on firewall rule $($FirewallRule.Name)" { | |
$result = Get-TargetResource -Name 'FirewallRule' | |
$result.Name | Should Be 'FirewallRule' | |
$result.Ensure | Should Be 'Absent' | |
} | |
} | |
Context 'Present should return correctly' { | |
$result = Get-TargetResource -Name $FirewallRule.Name | |
# Looping these tests | |
foreach ($parameter in $ParameterList) | |
{ | |
$ParameterSource = (Invoke-Expression -Command "`$($($parameter.source))") | |
$ParameterNew = (Invoke-Expression -Command "`$result.$($parameter.name)") | |
It "should have the correct $($parameter.Name) on firewall rule $($FirewallRule.Name)" { | |
$ParameterSource | Should Be $ParameterNew | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment