Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public sealed class WriteHostCommand : ConsoleColorCmdlet
/// </summary>

[Parameter(Position = 0, ValueFromRemainingArguments = true, ValueFromPipeline = true)]
[Alias("Msg", "Message")]
public object Object { get; set; } = null;

/// <summary>
Expand Down Expand Up @@ -141,4 +142,4 @@ protected override void ProcessRecord()

private Boolean _notAppendNewline = false;
}
} // namespace Microsoft.PowerShell.Commands
} // namespace Microsoft.PowerShell.Commands
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public sealed class WriteInformationCommand : PSCmdlet
/// Object to be sent to the Information stream.
/// </summary>
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)]
[Alias("Msg")]
[Alias("Msg", "Message")]
public Object MessageData { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Describe "Write-Host with TestHostCS" -Tags "CI" {
$testHostCSData = @(
@{ Name = 'defaults'; Command = "Write-Host a,b,c"; returnCount = 1; returnValue = @("White:Black:a b c:NewLine"); returnInfo = @("a b c") }
@{ Name = '-Object'; Command = "Write-Host -Object a,b,c"; returnCount = 1; returnValue = @("White:Black:a b c:NewLine"); returnInfo = @("a b c") }
@{ Name = '-Message'; Command = "Write-Host -Message a,b,c"; returnCount = 1; returnValue = @("White:Black:a b c:NewLine"); returnInfo = @("a b c") }
@{ Name = '-Msg'; Command = "Write-Host -Msg a,b,c"; returnCount = 1; returnValue = @("White:Black:a b c:NewLine"); returnInfo = @("a b c") }
@{ Name = '-Separator'; Command = "Write-Host a,b,c -Separator '+'"; returnCount = 1; returnValue = @("White:Black:a+b+c:NewLine"); returnInfo = @("a+b+c") }
@{ Name = '-Separator, colors and -NoNewLine'; Command = "Write-Host a,b,c -Separator ',' -ForegroundColor Yellow -BackgroundColor DarkBlue -NoNewline"; returnCount = 1; returnValue = @("Yellow:DarkBlue:a,b,c:NoNewLine"); returnInfo = @("a,b,c") }
@{ Name = '-NoNewline:$true and colors'; Command = "Write-Host a,b -NoNewline:`$true -ForegroundColor Red -BackgroundColor Green;Write-Host a,b"; returnCount = 2; returnValue = @("Red:Green:a b:NoNewLine", "White:Black:a b:NewLine"); returnInfo = @("a b", "a b") }
Expand All @@ -85,11 +87,11 @@ Describe "Write-Host with TestHostCS" -Tags "CI" {
$result = $th.ui.Streams.ConsoleOutput

$result.Count | Should Be $returnCount
(Compare-Object $result $returnValue -SyncWindow 0).length -eq 0 | Should Be $true
(Compare-Object $result $returnValue -SyncWindow 0).length | Should Be 0

$result = $th.ui.Streams.Information

$result.Count | Should Be $returnCount
(Compare-Object $result $returnInfo -SyncWindow 0).length -eq 0 | Should Be $true
(Compare-Object $result $returnInfo -SyncWindow 0).length | Should Be 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ Describe "Stream writer tests" -Tags "CI" {
Context "Write-Information cmdlet" {
BeforeAll {
$ps = [powershell]::Create()

$testInfoData = @(
@{ Name = 'defaults'; Command = "Write-Information TestMessage"; returnCount = 1; returnValue = 'TestMessage' }
@{ Name = '-Object'; Command = "Write-Information -MessageData TestMessage"; returnCount = 1; returnValue = 'TestMessage' }
@{ Name = '-Message'; Command = "Write-Information -Message TestMessage"; returnCount = 1; returnValue = 'TestMessage' }
@{ Name = '-Msg'; Command = "Write-Information -Msg TestMessage"; returnCount = 1; returnValue = 'TestMessage' }
@{ Name = '-Tag'; Command = "Write-Information TestMessage -Tag Test"; returnCount = 1; returnValue = 'TestMessage' }
)
}

BeforeEach {
Expand Down Expand Up @@ -96,5 +104,15 @@ Describe "Stream writer tests" -Tags "CI" {
$result[0].MessageData | Should be "teststring"
$result[1].MessageData | Should be "12345"
}

It "Write-Information works with <Name>" -TestCases:$testInfoData {
param($Command, $returnCount, $returnValue)
$ps.AddScript($Command).Invoke()

$result = $ps.Streams.Information

$result.Count | Should Be $returnCount
(Compare-Object $result $returnValue -SyncWindow 0).length | Should Be 0
}
}
}