forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOut-String.Tests.ps1
More file actions
48 lines (36 loc) · 1.69 KB
/
Copy pathOut-String.Tests.ps1
File metadata and controls
48 lines (36 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Describe "Out-String DRT Unit Tests" -Tags "CI" {
It "check display of properties with names containing wildcard characters" {
$results = new-object psobject | add-member -passthru noteproperty 'name with square brackets: [0]' 'myvalue' | out-string
$results.Length | Should BeGreaterThan 1
$results | Should BeOfType "System.String"
$results.Contains("myvalue") | Should Be $true
$results.Contains("name with square brackets: [0]") | Should Be $true
}
}
Describe "Out-String" -Tags "CI" {
BeforeAll {
$nl = [Environment]::NewLine
}
It "Should accumulate the strings and returns them as a single string" {
$testArray = "a", " b"
$testArray | Out-String | Should Be "a$nl b$nl"
,$($testArray | Out-String) | Should BeOfType "System.String"
}
It "Should be able to return an array of strings using the stream switch" {
$testInput = "a", "b"
,$($testInput | Out-String) | Should BeOfType "System.String"
,$($testInput | Out-String -Stream) | Should BeOfType "System.Array"
}
It "Should send all objects through a pipeline when not using the stream switch" {
$testInput = "a", "b"
$streamoutputlength = $($testInput | Out-String -Stream).Length
$nonstreamoutputlength = $($testInput | Out-String).Length
$nonstreamoutputlength| Should BeGreaterThan $streamoutputlength
}
It "Should send a single object through a pipeline when the stream switch is used" {
$testInput = "a", "b"
$streamoutputlength = $($testInput | Out-String -Stream).Length
$nonstreamoutputlength = $($testInput | Out-String).Length
$streamoutputlength | Should BeLessThan $nonstreamoutputlength
}
}