Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created December 17, 2015 21:37
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/07f0914ce00ae8a963df to your computer and use it in GitHub Desktop.
Save PlagueHO/07f0914ce00ae8a963df to your computer and use it in GitHub Desktop.
A Unit test of the xFirewall DSC Resource in the xNetworking module
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