MegaBites-AI/Windows-powershell
0308
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "Write-Progress DRT Unit Tests" -Tags "CI" {4 It "Should be able to throw exception when running Write-Progress with bad percentage" {5 { Write-Progress -Activity 'myactivity' -Status 'mystatus' -percent 101 } |6 Should -Throw -ErrorId 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.WriteProgressCommand'7 }8 9 It "Should be able to throw exception when running Write-Progress with bad parent id " {10 { Write-Progress -Activity 'myactivity' -Status 'mystatus' -Id 1 -ParentId -2 } |11 Should -Throw -ErrorId 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.WriteProgressCommand'12 }13 14 It "all mandatory params works" -Pending {15 { Write-Progress -Activity 'myactivity' -Status 'mystatus' } | Should -Not -Throw16 }17 18 It "all params works" -Pending {19 { Write-Progress -Activity 'myactivity' -Status 'mystatus' -Id 1 -ParentId 2 -Completed:$false -current 'current' -sec 1 -percent 1 } | Should -Not -Throw20 }21 22 It 'Activity longer than console width works' {23 try {24 $activity = 'a' * ([console]::WindowWidth + 1)25 } catch {26 Set-ItResult -Skipped -Because 'Console width is not supported'27 }28 29 { Write-Progress -Activity $activity -Status ('b' * ([console]::WindowWidth + 1)) -Id 1 } | Should -Not -Throw30 Write-Progress -Activity $activity -Id 1 -Completed31 }32 33 It 'Should be able to complete a progress record with no activity specified' {34 { Write-Progress -Completed } | Should -Not -Throw35 }36}37 