@@ -114,4 +114,69 @@ Describe "Settings Class" {
114114 $settings.RuleArguments [" PSProvideCommentHelp" ][" Placement" ] | Should Be ' end'
115115 }
116116 }
117+
118+ Context " When CustomRulePath parameter is provided" {
119+ It " Should return an array of 1 item when only 1 path is given in a hashtable" {
120+ $rulePath = " C:\rules\module1"
121+ $settingsHashtable = @ {
122+ CustomRulePath = $rulePath
123+ }
124+
125+ $settings = New-Object - TypeName $settingsTypeName - ArgumentList $settingsHashtable
126+ $settings.CustomRulePath.Count | Should Be 1
127+ $settings.CustomRulePath [0 ] | Should be $rulePath
128+ }
129+
130+ It " Should return an array of n items when n items are given in a hashtable" {
131+ $rulePaths = @ (" C:\rules\module1" , " C:\rules\module2" )
132+ $settingsHashtable = @ {
133+ CustomRulePath = $rulePaths
134+ }
135+
136+ $settings = New-Object - TypeName $settingsTypeName - ArgumentList $settingsHashtable
137+ $settings.CustomRulePath.Count | Should Be $rulePaths.Count
138+ 0 .. ($rulePaths.Count - 1 ) | ForEach-Object { $settings.CustomRulePath [$_ ] | Should be $rulePaths [$_ ] }
139+
140+ }
141+
142+ It " Should detect the parameter in a settings file" {
143+ $settings = New-Object - TypeName $settingsTypeName `
144+ - ArgumentList ([System.IO.Path ]::Combine($project1Root , " CustomRulePathSettings.psd1" ))
145+ $settings.CustomRulePath.Count | Should Be 2
146+ }
147+ }
148+
149+ @ (" IncludeDefaultRules" , " RecurseCustomRulePath" ) | ForEach-Object {
150+ $paramName = $_
151+ Context " When $paramName parameter is provided" {
152+ It " Should correctly set the value if a boolean is given - true" {
153+ $settingsHashtable = @ {}
154+ $settingsHashtable.Add ($paramName , $true )
155+
156+ $settings = New-Object - TypeName $settingsTypeName - ArgumentList $settingsHashtable
157+ $settings ." $paramName " | Should Be $true
158+ }
159+
160+ It " Should correctly set the value if a boolean is given - false" {
161+ $settingsHashtable = @ {}
162+ $settingsHashtable.Add ($paramName , $false )
163+
164+ $settings = New-Object - TypeName $settingsTypeName - ArgumentList $settingsHashtable
165+ $settings ." $paramName " | Should Be $false
166+ }
167+
168+ It " Should throw if a non-boolean value is given" {
169+ $settingsHashtable = @ {}
170+ $settingsHashtable.Add ($paramName , " some random string" )
171+
172+ { New-Object - TypeName $settingsTypeName - ArgumentList $settingsHashtable } | Should Throw
173+ }
174+
175+ It " Should detect the parameter in a settings file" {
176+ $settings = New-Object - TypeName $settingsTypeName `
177+ - ArgumentList ([System.IO.Path ]::Combine($project1Root , " CustomRulePathSettings.psd1" ))
178+ $settings ." $paramName " | Should Be $true
179+ }
180+ }
181+ }
117182}
0 commit comments