Skip to content

Commit cb58f69

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 174f0cb commit cb58f69

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

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

0 commit comments

Comments
 (0)