Skip to content

Commit 9de8dce

Browse files
committed
(GH-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 ca50b3c commit 9de8dce

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
@@ -276,5 +276,57 @@ [string] TestMethod() {
276276

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

0 commit comments

Comments
 (0)