Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hughes committed Nov 7, 2024
1 parent 6a6b826 commit d1b74a2
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/unit/private/Get-ClassResourceProperty.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Remove-Module -Name $script:moduleName -Force -ErrorAction 'SilentlyContinue'
Import-Module $script:moduleName -Force -ErrorAction 'Stop'
#endregion HEADER

Describe 'Get-ClassResourceProperty' {
InModuleScope $script:moduleName {
InModuleScope $script:moduleName {
Describe 'Get-ClassResourceProperty' {
Context 'When the resource has a parent class that also has a DSC property' {
BeforeAll {
$mockBuiltModulePath = Join-Path -Path $TestDrive -ChildPath 'output\MyClassModule\1.0.0'
Expand Down Expand Up @@ -175,9 +175,7 @@ class ResourceBase
$ensurePropertyResult.ValueMap | Should -Contain 'Down'
}
}
}

InModuleScope $script:moduleName {
Context 'When the resource has a parent class that does not have a source file (part of another module)' {
BeforeAll {
$mockBuiltModulePath = Join-Path -Path $TestDrive -ChildPath 'output\MyClassModule\1.0.0'
Expand Down Expand Up @@ -274,6 +272,7 @@ class MyDscResource

$dscProperties = $dscClassInModule.GetProperties() | Where-Object { 'DscPropertyAttribute' -in $_.CustomAttributes.AttributeType.Name }
}

It 'Should return the expected DSC class resource properties' {
$mockGetClassResourcePropertyParameters = @{
SourcePath = $mockSourcePath
Expand Down Expand Up @@ -301,9 +300,7 @@ class MyDscResource
$ensurePropertyResult.ValueMap | Should -Contain 'Down'
}
}
}

InModuleScope $script:moduleName {
Context 'When a base class is missing comment-based help' {
BeforeAll {
$mockBuiltModulePath = Join-Path -Path $TestDrive -ChildPath 'output\MyClassModule\1.0.0'
Expand Down Expand Up @@ -451,9 +448,7 @@ DescriptionTestProperty description. This is a second row with various tests lik
$ensurePropertyResult.IsArray | Should -BeFalse
}
}
}

InModuleScope $script:moduleName {
Context 'When two script file names end with similar name' {
BeforeAll {
$mockBuiltModulePath = Join-Path -Path $TestDrive -ChildPath 'output\MyClassModule\1.0.0'
Expand Down Expand Up @@ -566,7 +561,7 @@ $Ensure
$mockBaseClassSourceScript | Microsoft.PowerShell.Utility\Out-File -FilePath "$mockSourcePath\Classes\001.BaseMyDscResource.ps1" -Encoding ascii -Force

[System.IO.FileInfo] $mockBuiltModuleFile = Join-Path -Path $mockBuiltModulePath -ChildPath 'MyClassModule.psm1'
Import-Module -Name $mockBuiltModuleFile.FullName
Import-Module -Name $mockBuiltModuleFile.FullName -Force

$classesInModule = (Get-Module $mockBuiltModuleFile.BaseName).ImplementingAssembly.DefinedTypes | Where-Object { $_.IsClass -and $_.IsPublic }
$dscClassInModule = $classesInModule | Where-Object { 'DscResourceAttribute' -in $_.CustomAttributes.AttributeType.Name }
Expand Down

0 comments on commit d1b74a2

Please sign in to comment.