Fixing progress for Get-ComputerInfo (#9236)
This commit is contained in:
parent
074b344133
commit
4ec36a0d4a
|
@ -85,7 +85,6 @@ namespace Microsoft.PowerShell.Commands
|
||||||
|
|
||||||
#region Instance Data
|
#region Instance Data
|
||||||
private string _machineName = localMachineName; // we might need to have cmdlet work on another machine
|
private string _machineName = localMachineName; // we might need to have cmdlet work on another machine
|
||||||
private ProgressRecord _progress = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collection of property names from the Property parameter,
|
/// Collection of property names from the Property parameter,
|
||||||
|
@ -225,17 +224,10 @@ namespace Microsoft.PowerShell.Commands
|
||||||
/// </param>
|
/// </param>
|
||||||
private void UpdateProgress(string status)
|
private void UpdateProgress(string status)
|
||||||
{
|
{
|
||||||
if (_progress != null)
|
ProgressRecord progress = new ProgressRecord(0, activity, status ?? ComputerResources.ProgressStatusCompleted);
|
||||||
{
|
progress.RecordType = status == null ? ProgressRecordType.Completed : ProgressRecordType.Processing;
|
||||||
_progress.RecordType = ProgressRecordType.Completed;
|
|
||||||
WriteProgress(_progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != null)
|
WriteProgress(progress);
|
||||||
{
|
|
||||||
_progress = new ProgressRecord(0, activity, status);
|
|
||||||
WriteProgress(_progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1010,6 +1010,18 @@ try {
|
||||||
$computerInfo = Get-ComputerInfo
|
$computerInfo = Get-ComputerInfo
|
||||||
$computerInfo | Should -BeOfType 'Microsoft.PowerShell.Commands.ComputerInfo'
|
$computerInfo | Should -BeOfType 'Microsoft.PowerShell.Commands.ComputerInfo'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It "Verify progress records in Get-ComputerInfo" {
|
||||||
|
try {
|
||||||
|
$j = Start-Job { Get-ComputerInfo }
|
||||||
|
$j | Wait-Job
|
||||||
|
$j.ChildJobs[0].Progress | Should -HaveCount 9
|
||||||
|
$j.ChildJobs[0].Progress[-1].RecordType | Should -Be ([System.Management.Automation.ProgressRecordType]::Completed)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
$j | Remove-Job
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "Tests for Get-ComputerInfo" -tags "Feature", "RequireAdminOnWindows" {
|
Describe "Tests for Get-ComputerInfo" -tags "Feature", "RequireAdminOnWindows" {
|
||||||
|
|
Loading…
Reference in a new issue