From 29800144636486f377efad090bc1e0e83df29e26 Mon Sep 17 00:00:00 2001 From: TingLiu6 Date: Mon, 25 Apr 2016 02:10:17 -0700 Subject: [PATCH] Add Unit Test for Write-Progress --- test/powershell/Write-Progress.Tests.ps1 | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/powershell/Write-Progress.Tests.ps1 diff --git a/test/powershell/Write-Progress.Tests.ps1 b/test/powershell/Write-Progress.Tests.ps1 new file mode 100644 index 0000000000..0ea87cc9d4 --- /dev/null +++ b/test/powershell/Write-Progress.Tests.ps1 @@ -0,0 +1,45 @@ +Describe "Write-Progress DRT Unit Tests" -Tags DRT{ + It "Should be able to throw exception when missing mandatory parameters" { + try + { + Write-Progress $null + Throw "Execution OK" + } + catch + { + $_.FullyQualifiedErrorId | Should Be 'ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.WriteProgressCommand' + } + } + + It "Should be able to throw exception when running Write-Progress with bad percentage" { + try + { + write-progress -activity 'myactivity' -status 'mystatus' -percent 101 + Throw "Execution OK" + } + catch + { + $_.FullyQualifiedErrorId | Should Be 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.WriteProgressCommand' + } + } + + It "Should be able to throw exception when running Write-Progress with bad parent id " { + try + { + write-progress -activity 'myactivity' -status 'mystatus' -id 1 -parentid -2 + Throw "Execution OK" + } + catch + { + $_.FullyQualifiedErrorId | Should Be 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.WriteProgressCommand' + } + } + + It "all mandatory params works" { + { write-progress -activity 'myactivity' -status 'mystatus' } | Should Not Throw + } + + It "all params works" { + { write-progress -activity 'myactivity' -status 'mystatus' -id 1 -parentId 2 -completed:$false -current 'current' -sec 1 -percent 1 } | Should Not Throw + } +} \ No newline at end of file