Skip to content

Commit 5ffd49f

Browse files
committed
(PowerShellGH-812) Update folder for DSC style scripts
Previously the code folding was not tested against DSC configuration scripts. This commit adds tests for a sample DSC script to ensure the folding occurs at the correct places
1 parent 64fb15b commit 5ffd49f

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/PowerShellEditorServices.Test/Language/TokenOperationsTests.cs

+52
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,57 @@ [string] TestMethod() {
271271

272272
AssertFoldingReferenceArrays(expectedFolds, result);
273273
}
274+
275+
// This tests DSC style keywords and param blocks
276+
[Fact]
277+
public void LaguageServiceFindsFoldablRegionsWithDSC() {
278+
string testString =
279+
@"Configuration Example
280+
{
281+
param
282+
(
283+
[Parameter()]
284+
[System.String[]]
285+
$NodeName = 'localhost',
286+
287+
[Parameter(Mandatory = $true)]
288+
[ValidateNotNullorEmpty()]
289+
[System.Management.Automation.PSCredential]
290+
$Credential
291+
)
292+
293+
Import-DscResource -Module ActiveDirectoryCSDsc
294+
295+
Node $AllNodes.NodeName
296+
{
297+
WindowsFeature ADCS-Cert-Authority
298+
{
299+
Ensure = 'Present'
300+
Name = 'ADCS-Cert-Authority'
301+
}
302+
303+
AdcsCertificationAuthority CertificateAuthority
304+
{
305+
IsSingleInstance = 'Yes'
306+
Ensure = 'Present'
307+
Credential = $Credential
308+
CAType = 'EnterpriseRootCA'
309+
DependsOn = '[WindowsFeature]ADCS-Cert-Authority'
310+
}
311+
}
312+
}
313+
";
314+
FoldingReference[] expectedFolds = {
315+
CreateFoldingReference(1, 0, 33, 1, null),
316+
CreateFoldingReference(3, 4, 12, 5, null),
317+
CreateFoldingReference(17, 4, 32, 5, null),
318+
CreateFoldingReference(19, 8, 22, 9, null),
319+
CreateFoldingReference(25, 8, 31, 9, null)
320+
};
321+
322+
FoldingReference[] result = GetRegions(testString);
323+
324+
AssertFoldingReferenceArrays(expectedFolds, result);
325+
}
274326
}
275327
}

0 commit comments

Comments
 (0)