@@ -7,7 +7,6 @@ Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
77$ruleConfiguration = @ {
88 Enable = $true
99 CheckHashtable = $true
10- CheckDSCConfiguration = $true
1110}
1211
1312$settings = @ {
@@ -18,8 +17,8 @@ $settings = @{
1817}
1918
2019Describe " AlignAssignmentStatement" {
21- Context " Hashtable " {
22- It " Should align assignment statements in a hashtable when need to add whitespace " {
20+ Context " When assignment statements are in hashtable " {
21+ It " Should find violation when assignment statements are not aligned (whitespace needs to be added) " {
2322 $def = @'
2423$hashtable = @{
2524 property1 = "value"
@@ -38,7 +37,7 @@ $hashtable = @{
3837 Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
3938 }
4039
41- It " Should align assignment statements in a hashtable when need to remove whitespace " {
40+ It " Should find violation when assignment statements are not aligned (whitespace needs to be removed) " {
4241 $def = @'
4342$hashtable = @{
4443 property1 = "value"
@@ -56,5 +55,37 @@ $hashtable = @{
5655 $violations.Count | Should Be 1
5756 Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
5857 }
58+
59+ It " Should ignore if a hashtable is empty" {
60+ $def = @'
61+ $x = @{ }
62+ '@
63+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Get-Count | Should Be 0
64+
65+ }
66+ }
67+
68+ Context " When assignment statements are in DSC Configuration" {
69+ It " Should find violations when assignment statements are not aligned" {
70+ $def = @'
71+ Configuration MyDscConfiguration {
72+
73+ param(
74+ [string[]]$ComputerName="localhost"
75+ )
76+ Node $ComputerName {
77+ WindowsFeature MyFeatureInstance {
78+ Ensure = "Present"
79+ Name = "RSAT"
80+ }
81+ WindowsFeature My2ndFeatureInstance {
82+ Ensure = "Present"
83+ Name = "Bitlocker"
84+ }
85+ }
86+ }
87+ '@
88+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Get-Count | Should Be 2
89+ }
5990}
6091}
0 commit comments