Skip to content

Commit 365f337

Browse files
author
Kapil Borle
committed
Update 0 violation comparison in test cases
1 parent d81387d commit 365f337

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

Tests/Rules/UseConsistentWhitespace.tests.ps1

+11-22
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ if ($true){}
4141
$def = @'
4242
if($true) {}
4343
'@
44-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
45-
$violations.Count | Should Be 0
44+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
4645
}
4746

4847
It "Should not find violation if an open brace follows a foreach member invocation" {
@@ -83,8 +82,7 @@ function foo($param1) {
8382
8483
}
8584
'@
86-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
87-
$violations.Count | Should Be 0
85+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
8886
}
8987

9088
It "Should not find a violation in a param block" {
@@ -93,8 +91,7 @@ function foo() {
9391
param( )
9492
}
9593
'@
96-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
97-
$violations.Count | Should Be 0
94+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
9895
}
9996

10097
It "Should not find a violation in a nested open paren" {
@@ -103,16 +100,14 @@ function foo($param) {
103100
((Get-Process))
104101
}
105102
'@
106-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
107-
$violations.Count | Should Be 0
103+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
108104
}
109105

110106
It "Should not find a violation on a method call" {
111107
$def = @'
112108
$x.foo("bar")
113109
'@
114-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
115-
$violations.Count | Should Be 0
110+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
116111
}
117112
}
118113

@@ -162,16 +157,14 @@ $x = @"
162157
"abc"
163158
"@
164159
'@
165-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
166-
$violations.Count | Should Be 0
160+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
167161
}
168162

169163
It "Should not find violation if there are whitespaces of size 1 around an assignment operator for here string" {
170164
$def = @'
171165
$x = 1
172166
'@
173-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
174-
$violations.Count | Should Be 0
167+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
175168
}
176169

177170
It "Should not find violation if there are no whitespaces around DotDot operator" {
@@ -202,8 +195,7 @@ $x = @(1,2)
202195
$def = @'
203196
$x = @(1, 2)
204197
'@
205-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
206-
$violations.Count | Should Be 0
198+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
207199
}
208200
}
209201

@@ -227,8 +219,7 @@ $x = @{a=1;b=2}
227219
$def = @'
228220
$x = @{a=1; b=2}
229221
'@
230-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
231-
$violations.Count | Should Be 0
222+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
232223
}
233224

234225
It "Should not find a violation if a new-line follows a semi-colon" {
@@ -238,16 +229,14 @@ $x = @{
238229
b=2
239230
}
240231
'@
241-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
242-
$violations.Count | Should Be 0
232+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
243233
}
244234

245235
It "Should not find a violation if a end of input follows a semi-colon" {
246236
$def = @'
247237
$x = "abc";
248238
'@
249-
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
250-
$violations.Count | Should Be 0
239+
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
251240
}
252241

253242

0 commit comments

Comments
 (0)