2016-03-04 23:48:30 +01:00
|
|
|
Describe "Write-Output" {
|
|
|
|
$testString = $testString
|
|
|
|
Context "Input Tests" {
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should allow piped input" {
|
|
|
|
{ $testString | Write-Output } | Should Not Throw
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should write output to the output stream when using piped input" {
|
|
|
|
$testString | Write-Output | Should Be $testString
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should use inputobject switch" {
|
|
|
|
{ Write-Output -InputObject $testString } | Should Not Throw
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should write output to the output stream when using inputobject switch" {
|
|
|
|
Write-Output -InputObject $testString | Should Be $testString
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to write to a variable" {
|
|
|
|
Write-Output -InputObject $testString -OutVariable var
|
|
|
|
$var | Should Be $testString
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Pipeline Command Tests" {
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should send object to the next command in the pipeline" {
|
|
|
|
Write-Output -InputObject (1+1) | Should Be 2
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should have the same result between inputobject switch and piped input" {
|
|
|
|
Write-Output -InputObject (1+1) | Should Be 2
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
1+1 | Write-Output | Should Be 2
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Alias Tests" {
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should have the same result between the echo alias and the cmdlet" {
|
|
|
|
$alias = echo -InputObject $testString
|
|
|
|
$cmdlet = Write-Output -InputObject $testString
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$alias | Should Be $cmdlet
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should have the same result between the write alias and the cmdlet" {
|
|
|
|
$alias = write -InputObject $testString
|
|
|
|
$cmdlet = Write-Output -InputObject $testString
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$alias | Should Be $cmdlet
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Enumerate Objects" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$enumerationObject = @(1,2,3)
|
|
|
|
It "Should see individual objects when not using the NoEnumerate switch" {
|
|
|
|
$singleCollection = $(Write-Output $enumerationObject| Measure-Object).Count
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$singleCollection | Should Be $enumerationObject.length
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to treat a collection as a single object using the NoEnumerate switch" {
|
|
|
|
$singleCollection = $(Write-Output $enumerationObject -NoEnumerate | Measure-Object).Count
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$singleCollection | Should Be 1
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
}
|