Skip to content

Commit 15b6a93

Browse files
committed
update test case to use -testcase struct
1 parent 23ea68a commit 15b6a93

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

test/powershell/Modules/Microsoft.PowerShell.Management/Get-Content.Tests.ps1

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -287,26 +287,15 @@ baz
287287
}
288288

289289
Describe "Get-Content -Raw test" -Tags "CI" {
290-
BeforeAll {
291-
$lfTextUnterminated = "a`nb"
292-
$lfText = "a`nb`n"
293-
$crlfTextUnterminated = "a`r`nb"
294-
$crlfText = "a`r`nb`r`n"
295-
Set-Content -Encoding Ascii -NoNewline "$TestDrive\lf.txt" -value $lfText
296-
Set-Content -Encoding Ascii -NoNewline "$TestDrive\crlf.txt" -value $crlfText
297-
Set-Content -Encoding Ascii -NoNewline "$TestDrive\lf-nt.txt" -value $lfTextUnterminated
298-
Set-Content -Encoding Ascii -NoNewline "$TestDrive\crlf-nt.txt" -value $crlfTextUnterminated
299-
}
300-
It "Reads LF-terminated files in full." {
301-
Get-Content -Raw "$TestDrive\lf.txt" | Should BeExactly $lfText
302-
}
303-
It "Reads CRLF-terminated files in full." {
304-
Get-Content -Raw "$TestDrive\crlf.txt" | Should BeExactly $crlfText
305-
}
306-
It "Reads LF-separated files without trailing newline in full." {
307-
Get-Content -Raw "$TestDrive\lf-nt.txt" | Should BeExactly $lfTextUnterminated
308-
}
309-
It "Reads CRLF-separated files without trailing newline in full." {
310-
Get-Content -Raw "$TestDrive\crlf-nt.txt" | Should BeExactly $crlfTextUnterminated
290+
291+
It "Reads - <testname> in full" -TestCases @(
292+
@{character = "a`nb`n"; testname = "LF-terminated files"; filename = "lf.txt"}
293+
@{character = "a`r`nb`r`n"; testname = "CRLF-terminated files"; filename = "crlf.txt"}
294+
@{character = "a`nb"; testname = "LF-separated files without trailing newline"; filename = "lf-nt.txt"}
295+
@{character = "a`r`nb"; testname = "CRLF-separated files without trailing newline"; filename = "crlf-nt.txt"}
296+
) {
297+
param ($character, $filename)
298+
Set-Content -Encoding Ascii -NoNewline "$TestDrive\$filename" -value $character
299+
Get-Content -Raw "$TestDrive\$filename" | Should BeExactly $character
311300
}
312301
}

0 commit comments

Comments
 (0)