Tests/cChoco_xDscResourceTests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#---------------------------------#
# xDscResourceTests Pester #
#---------------------------------#
$DSC = Get-DscResource | Where-Object {$_.Module.Name -eq 'cChoco'}

Describe 'Testing all DSC resources using xDscResource designer.' {
  foreach ($Resource in $DSC)
  { 
    if (-not ($Resource.ImplementedAs -eq 'Composite') ) {
      $ResourceName = $Resource.ResourceType
      $Mof          = Get-ChildItem “$PSScriptRoot\..\” -Filter "$resourcename.schema.mof" -Recurse 
      
      Context “Testing DscResource '$ResourceName' using Test-xDscResource” {
        It 'Test-xDscResource should return $true' {
          Test-xDscResource -Name $ResourceName | Should Be $true
        }    
      }

      Context “Testing DscSchema '$ResourceName' using Test-xDscSchema” {
        It 'Test-xDscSchema should return true' {
          Test-xDscSchema -Path $Mof.FullName | Should Be $true
        }    
      }
    }
  }
}