diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs index f7f8c24bc4..5aed01c5d3 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs @@ -28,6 +28,7 @@ namespace Microsoft.PowerShell.Commands /// [Parameter(Position = 0, ValueFromRemainingArguments = true, ValueFromPipeline = true)] + [Alias("Msg", "Message")] public object Object { get; set; } = null; /// @@ -141,4 +142,4 @@ namespace Microsoft.PowerShell.Commands private Boolean _notAppendNewline = false; } -} // namespace Microsoft.PowerShell.Commands \ No newline at end of file +} // namespace Microsoft.PowerShell.Commands diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs index 6d5ccb134c..4717ff4db7 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/write.cs @@ -168,7 +168,7 @@ namespace Microsoft.PowerShell.Commands /// Object to be sent to the Information stream. /// [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)] - [Alias("Msg")] + [Alias("Msg", "Message")] public Object MessageData { get; set; } /// diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Host.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Host.Tests.ps1 index 97b56290a3..c3fbf1afaf 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Host.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Host.Tests.ps1 @@ -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") } @@ -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 } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 index dab0d03c22..83e286b728 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1 @@ -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 { @@ -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 " -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 + } } }