From 19358f80600141a549a3e0c297bfbfddd5da7299 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 18 Nov 2015 15:59:00 -0800 Subject: [PATCH 1/2] added write-error tests --- src/pester-tests/Write-Error.Tests.ps1 | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/pester-tests/Write-Error.Tests.ps1 diff --git a/src/pester-tests/Write-Error.Tests.ps1 b/src/pester-tests/Write-Error.Tests.ps1 new file mode 100644 index 0000000000..e8390188f3 --- /dev/null +++ b/src/pester-tests/Write-Error.Tests.ps1 @@ -0,0 +1,35 @@ +Describe "Write-Error" { + It "Should be able to throw" { + Write-Error "test throw" -ErrorAction SilentlyContinue | Should Throw + } + + It "Should throw a non-terminating error" { + Write-Error "test throw" -ErrorAction SilentlyContinue + + 1 + 1 | Should Be 2 + } + + It "Should trip an exception using the exception switch" { + $var = 0 + try + { + Write-Error -Exception -Message "test throw" + } + catch [System.Exception] + { + + $var++ + } + finally + { + $var | Should Be 1 + } + } + + It "Should output the error message to the `$error automatic variable" { + $theError = "Error: Too many input values." + write-error -message $theError -category InvalidArgument -ErrorAction SilentlyContinue + + $error[0]| Should Be $theError + } +} \ No newline at end of file From 5b433eee8858c31a3a4c4260e0ee2e7b7a0597d1 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 18 Nov 2015 16:29:52 -0800 Subject: [PATCH 2/2] for jenkins build and creating PR