File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,27 @@ Describe "UseCorrectCasing" {
103103 Should - BeExactly ' $A++; $B--'
104104 }
105105
106+ It " Shows relevant diagnostic message for function/command name casing" {
107+ $settings = @ { ' Rules' = @ { ' PSUseCorrectCasing' = @ { ' Enable' = $true ; CheckCommands = $true ; CheckKeywords = $true ; CheckOperators = $true } } }
108+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition ' WHERE-OBJECT Name -EQ "Value"' - Settings $settings
109+ $violations.Count | Should - Be 1
110+ $violations [0 ].Message | Should - Be " Function/Cmdlet 'WHERE-OBJECT' does not match its exact casing 'Where-Object'."
111+ }
112+
113+ It " Shows relevant diagnostic message for parameter casing" {
114+ $settings = @ { ' Rules' = @ { ' PSUseCorrectCasing' = @ { ' Enable' = $true ; CheckCommands = $true ; CheckKeywords = $true ; CheckOperators = $true } } }
115+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition ' Where-Object Name -eq "Value"' - Settings $settings
116+ $violations.Count | Should - Be 1
117+ $violations [0 ].Message | Should - Be " Parameter '-eq' of function/cmdlet 'Where-Object' does not match its exact casing 'EQ'."
118+ }
119+
120+ It " Shows relevant diagnostic message for operator casing" {
121+ $settings = @ { ' Rules' = @ { ' PSUseCorrectCasing' = @ { ' Enable' = $true ; CheckCommands = $true ; CheckKeywords = $true ; CheckOperators = $true } } }
122+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition ' $a -EQ 1' - Settings $settings
123+ $violations.Count | Should - Be 1
124+ $violations [0 ].Message | Should - Be " Operator '-EQ' does not match the expected case '-eq'."
125+ }
126+
106127 Context " Inconsistent Keywords" {
107128 It " Corrects keyword case" {
108129 Invoke-Formatter ' ForEach ($x IN $y) { $x }' |
You can’t perform that action at this time.
0 commit comments