10000 address Jim's feedback · PowerShell/PowerShell@4b69e9a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b69e9a

Browse files
committed
address Jim's feedback
refactor existing tests to have better description and use -TestCases
1 parent 06ba885 commit 4b69e9a

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,23 @@ Describe "Format-Table DRT Unit Tests" -Tags "CI" {
137137
$result | Should Match "Jim\s+5678\s+False"
138138
}
139139

140-
It "Format-Table with No Objects for End-To-End should work"{
141-
$p = @{}
142-
$result = $p | Format-Table -Property "foo","bar" | Out-String
140+
It "Format-Table with '<testName>' should return `$null" -TestCases @(
141+
@{ testName = "empty array"; testObject = @{} },
142+
@{ testName = "null" ; testObject = $null }
143+
) {
144+
param ($testObject)
145+
$result = $testObject | Format-Table -Property "foo","bar" | Out-String
143146
$result | Should BeNullOrEmpty
144147
}
145148

146-
It "Format-Table with Null Objects for End-To-End should work"{
147-
$p = $null
148-
$result = $p | Format-Table -Property "foo","bar" | Out-String
149-
$result | Should BeNullOrEmpty
150-
}
151-
152-
It "Format-Table with single line string for End-To-End should work" {
153-
$p = "single line string"
154-
$result = $p | Format-Table -Property "foo","bar" -Force | Out-String
155-
$result.Replace(" ","").Replace([Environment]::NewLine,"") | Should BeExactly "foobar------"
156-
}
157-
158-
It "Format-Table with multiple line string for End-To-End should work" {
159-
$p = "Line1`nLine2"
160-
$result = $p | Format-Table -Property "foo","bar" -Force | Out-String
161-
$result.Replace(" ","").Replace([Environment]::NewLine,"") | Should BeExactly "foobar------"
162-
}
163-
164-
It "Format-Table with string sequence for End-To-End should work" {
165-
$p = "Line1","Line2"
166-
$result = $p | Format-Table -Property "foo","bar" -Force | Out-String
167-
$result.Replace(" ","").Replace([Environment]::NewLine,"") | Should BeExactly "foobar------"
149+
It "Format-Table with '<testName>' string and -Force should output table with requested properties" -TestCases @(
150+
@{ testName = "single line"; testString = "single line string" },
151+
@{ testName = "multi line" ; testString = "line1`nline2" },
152+
@{ testName = "array" ; testString = "line1","line2" }
153+
) {
154+
param ($testString)
155+
$result = $testString | Format-Table -Property "foo","bar" -Force | Out-String
156+
$result.Replace(" ","").Replace([Environment]::NewLine,"") | Should BeExactly "foobar------"
168157
}
169158

170159
It "Format-Table with complex object for End-To-End should work" {

0 commit comments

Comments
 (0)
0