Skip to content

Commit 97d77a9

Browse files
committed
add tests and add alternative default reference if only wps is targeted
1 parent a5cc361 commit 97d77a9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Rules/UseCompatibleCmdlets.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private struct RuleParameters
4343
private bool hasInitializationError;
4444
private string reference;
4545
private readonly string defaultReference = "desktop-5.1.14393.206-windows";
46+
private readonly string alternativeDefaultReference = "core-6.0.2-windows";
4647
private RuleParameters ruleParameters;
4748

4849
public UseCompatibleCmdlets()
@@ -274,6 +275,10 @@ private void SetupCmdletsDictionary()
274275

275276
ruleParameters.compatibility = compatibilityList.ToArray();
276277
reference = defaultReference;
278+
if (compatibilityList.Count == 1 && compatibilityList[0] == defaultReference)
279+
{
280+
reference = alternativeDefaultReference;
281+
}
277282
#if DEBUG
278283
// Setup reference file
279284
object referenceObject;

Tests/Rules/UseCompatibleCmdlets.tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ Describe "UseCompatibleCmdlets" {
5454
@("Start-VM", "New-SmbShare", "Get-Disk") | `
5555
Test-Command -Settings $settings -ExpectedViolations 1
5656
}
57+
58+
Context "Default reference can also be used as target platform" {
59+
$settings = @{rules=@{PSUseCompatibleCmdlets=@{compatibility=@("desktop-5.1.14393.206-windows")}}}
60+
@("Remove-Service") | Test-Command -Settings $settings -ExpectedViolations 1
61+
}
5762
}

0 commit comments

Comments
 (0)