File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- Import-Module PSScriptAnalyzer
2- $ruleName = " AlignAssignmentStatement"
1+ $directory = Split-Path - Parent $MyInvocation.MyCommand.Path
2+ $testRootDirectory = Split-Path - Parent $directory
3+
4+ Import-Module PSScriptAnalyzer
5+ Import-Module (Join-Path $testRootDirectory " PSScriptAnalyzerTestHelper.psm1" )
6+
7+ $ruleConfiguration = @ {
8+ Enable = $true
9+ AlignInHashtable = $true
10+ AlignInDSCConfiguration = $true
11+ }
12+
13+ $settings = @ {
14+ IncludeRules = @ (" PSAlignAssignmentStatement" )
15+ Rules = @ {
16+ PSAlignAssignmentStatement = $ruleConfiguration
17+ }
18+ }
319
420Describe " AlignAssignmentStatement" {
5- Context " " {
6- It " " {
21+ Context " Hashtable" {
22+ It " Should align assignment statements in a hashtable" {
23+ $def = @'
24+ $hashtable = @{
25+ property1 = "value"
26+ anotherProperty = "another value"
27+ }
28+ '@
29+
30+ # Expected output should be the following
31+ # $hashtable = @{
32+ # property1 = "value"
33+ # anotherProperty = "another value"
34+ # }
35+
36+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
37+ $violations.Count | Should Be 1
38+ Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
739 }
840 }
941}
You can’t perform that action at this time.
0 commit comments