Skip to content

Commit

Permalink
(GH-812) Update folder for DSC style scripts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
glennsarti committed Dec 15, 2018
1 parent fd881f7 commit 420f9a0
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,57 @@ [string] TestMethod() {

FoldingReference[] result = GetRegions(testString);
}

// This tests DSC style keywords and param blocks
[Fact]
public void LaguageServiceFindsFoldablRegionsWithDSC() {
string testString =
@"Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty()]
[System.Management.Automation.PSCredential]
$Credential
)
Import-DscResource -Module ActiveDirectoryCSDsc
Node $AllNodes.NodeName
{
WindowsFeature ADCS-Cert-Authority
{
Ensure = 'Present'
Name = 'ADCS-Cert-Authority'
}
AdcsCertificationAuthority CertificateAuthority
{
IsSingleInstance = 'Yes'
Ensure = 'Present'
Credential = $Credential
CAType = 'EnterpriseRootCA'
DependsOn = '[WindowsFeature]ADCS-Cert-Authority'
}
}
}
";
FoldingReference[] expectedFolds = {
CreateFoldingReference(1, 0, 33, 1, null),
CreateFoldingReference(3, 4, 12, 5, null),
CreateFoldingReference(17, 4, 32, 5, null),
CreateFoldingReference(19, 8, 22, 9, null),
CreateFoldingReference(25, 8, 31, 9, null)
};

FoldingReference[] result = GetRegions(testString);

AssertFoldingReferenceArrays(expectedFolds, result);
}
}
}

0 comments on commit 420f9a0

Please sign in to comment.