@@ -7,7 +7,6 @@ Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
7
7
$ruleConfiguration = @ {
8
8
Enable = $true
9
9
CheckHashtable = $true
10
- CheckDSCConfiguration = $true
11
10
}
12
11
13
12
$settings = @ {
@@ -18,8 +17,8 @@ $settings = @{
18
17
}
19
18
20
19
Describe " 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) " {
23
22
$def = @'
24
23
$hashtable = @{
25
24
property1 = "value"
@@ -38,7 +37,7 @@ $hashtable = @{
38
37
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
39
38
}
40
39
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) " {
42
41
$def = @'
43
42
$hashtable = @{
44
43
property1 = "value"
@@ -56,5 +55,37 @@ $hashtable = @{
56
55
$violations.Count | Should Be 1
57
56
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
58
57
}
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
+ }
59
90
}
60
91
}
0 commit comments