File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,15 @@ public class Settings
32
32
private List < string > includeRules ;
33
33
private List < string > excludeRules ;
34
34
private List < string > severities ;
35
+ private List < string > customRulePath ;
35
36
private Dictionary < string , Dictionary < string , object > > ruleArguments ;
36
37
38
+ // todo use 'lambda' expression type getter
37
39
public string FilePath { get { return filePath ; } }
38
40
public IEnumerable < string > IncludeRules { get { return includeRules ; } }
39
41
public IEnumerable < string > ExcludeRules { get { return excludeRules ; } }
40
42
public IEnumerable < string > Severities { get { return severities ; } }
43
+ public IEnumerable < string > CustomRulePath => customRulePath ;
41
44
public Dictionary < string , Dictionary < string , object > > RuleArguments { get { return ruleArguments ; } }
42
45
43
46
/// <summary>
@@ -400,6 +403,10 @@ private void parseSettingsHashtable(Hashtable settingsHashtable)
400
403
excludeRules = GetData ( val , key ) ;
401
404
break ;
402
405
406
+ case "customrulepath" :
407
+ customRulePath = GetData ( val , key ) ;
408
+ break ;
409
+
403
410
case "rules" :
404
411
try
405
412
{
Original file line number Diff line number Diff line change @@ -114,4 +114,28 @@ Describe "Settings Class" {
114
114
$settings.RuleArguments [" PSProvideCommentHelp" ][" Placement" ] | Should Be ' end'
115
115
}
116
116
}
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
+ }
117
141
}
You can’t perform that action at this time.
0 commit comments