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
3232 private List < string > includeRules ;
3333 private List < string > excludeRules ;
3434 private List < string > severities ;
35+ private List < string > customRulePath ;
3536 private Dictionary < string , Dictionary < string , object > > ruleArguments ;
3637
38+ // todo use 'lambda' expression type getter
3739 public string FilePath { get { return filePath ; } }
3840 public IEnumerable < string > IncludeRules { get { return includeRules ; } }
3941 public IEnumerable < string > ExcludeRules { get { return excludeRules ; } }
4042 public IEnumerable < string > Severities { get { return severities ; } }
43+ public IEnumerable < string > CustomRulePath => customRulePath ;
4144 public Dictionary < string , Dictionary < string , object > > RuleArguments { get { return ruleArguments ; } }
4245
4346 /// <summary>
@@ -400,6 +403,10 @@ private void parseSettingsHashtable(Hashtable settingsHashtable)
400403 excludeRules = GetData ( val , key ) ;
401404 break ;
402405
406+ case "customrulepath" :
407+ customRulePath = GetData ( val , key ) ;
408+ break ;
409+
403410 case "rules" :
404411 try
405412 {
Original file line number Diff line number Diff line change @@ -114,4 +114,28 @@ 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+ }
117141}
You can’t perform that action at this time.
0 commit comments