From 346dc91eb5aa80370839a941227f9f71e0a70f90 Mon Sep 17 00:00:00 2001 From: Christoph Hannappel <37103421+ChristophHannappel@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:46:30 +0100 Subject: [PATCH 1/4] Adds Test for correct ResourceIds --- tests/Unit/DSCResources/DscResources.Tests.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Unit/DSCResources/DscResources.Tests.ps1 b/tests/Unit/DSCResources/DscResources.Tests.ps1 index c74414d..09ed3c1 100644 --- a/tests/Unit/DSCResources/DscResources.Tests.ps1 +++ b/tests/Unit/DSCResources/DscResources.Tests.ps1 @@ -104,6 +104,20 @@ configuration "Config_$dscResourceName" { $mofFile | Should -BeOfType System.IO.FileInfo } + It "'$dscResourceName' has ResourceIDs ending with [$dscResourceName]$dscResourceName" { + if ($dscResourceName -in $skippedDscResources) + { + Set-ItResult -Skipped -Because "Tests for '$dscResourceName' are skipped" + } + $mofContent = Get-Content -Raw -Path "$($OutputDirectory)\localhost_$dscResourceName.mof" + $selectString = Select-String -InputObject $mofContent -Pattern 'ResourceID = ".+' -AllMatches + foreach ($value in $selectString.Matches | Select-Object -ExpandProperty Value) + { + $value | Should -Match -RegularExpression "(ResourceID = `".*)(:{2}\[$dscResourceName\]$dscResourceName`";)" + } + } + + AfterAll { Remove-Item -Path C:\Temp\JeaRoleTest.ps1 if (-not $tempExists) From 4773d43f1b67e82032ce69f57dacece23ac7837d Mon Sep 17 00:00:00 2001 From: Christoph Hannappel <37103421+ChristophHannappel@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:51:29 +0100 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb1b98b..ee1a4e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Test the compiled Mof File if the RessourceID ends with the ResourceName + ### Fixed - DscTagging: Added parameter 'BuildNumber'. From 709f310b2fe2788540905dcec75afe8d5a12b552 Mon Sep 17 00:00:00 2001 From: Christoph Hannappel <37103421+ChristophHannappel@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:58:10 +0100 Subject: [PATCH 3/4] Fixes If statement --- tests/Unit/DSCResources/DscResources.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Unit/DSCResources/DscResources.Tests.ps1 b/tests/Unit/DSCResources/DscResources.Tests.ps1 index 09ed3c1..1b89c7e 100644 --- a/tests/Unit/DSCResources/DscResources.Tests.ps1 +++ b/tests/Unit/DSCResources/DscResources.Tests.ps1 @@ -104,8 +104,8 @@ configuration "Config_$dscResourceName" { $mofFile | Should -BeOfType System.IO.FileInfo } - It "'$dscResourceName' has ResourceIDs ending with [$dscResourceName]$dscResourceName" { - if ($dscResourceName -in $skippedDscResources) + It "'' has ResourceIDs ending with []" { + if ($Skip) { Set-ItResult -Skipped -Because "Tests for '$dscResourceName' are skipped" } From 823516a3f081fa3635e1136b442410e0654d7746 Mon Sep 17 00:00:00 2001 From: Christoph Hannappel <37103421+ChristophHannappel@users.noreply.github.com> Date: Tue, 10 Mar 2026 20:03:59 +0100 Subject: [PATCH 4/4] Update DscResources.Tests.ps1 --- tests/Unit/DSCResources/DscResources.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/DSCResources/DscResources.Tests.ps1 b/tests/Unit/DSCResources/DscResources.Tests.ps1 index 1b89c7e..5f84b42 100644 --- a/tests/Unit/DSCResources/DscResources.Tests.ps1 +++ b/tests/Unit/DSCResources/DscResources.Tests.ps1 @@ -104,7 +104,7 @@ configuration "Config_$dscResourceName" { $mofFile | Should -BeOfType System.IO.FileInfo } - It "'' has ResourceIDs ending with []" { + It "'' has ResourceIDs ending with []" -TestCases $testCases { if ($Skip) { Set-ItResult -Skipped -Because "Tests for '$dscResourceName' are skipped"