From 4ba7f81274cdf15a7ece6ed7dbce009719744bcd Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Thu, 19 Nov 2015 06:22:06 +0000 Subject: [PATCH] Added pester tests for Measure-Command --- src/pester-tests/Measure-Command.Tests.ps1 | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/pester-tests/Measure-Command.Tests.ps1 diff --git a/src/pester-tests/Measure-Command.Tests.ps1 b/src/pester-tests/Measure-Command.Tests.ps1 new file mode 100644 index 0000000000..77029a322b --- /dev/null +++ b/src/pester-tests/Measure-Command.Tests.ps1 @@ -0,0 +1,28 @@ +$here = Split-Path -Parent $MyInvocation.MyCommand.Path + +Describe "Measure-Command" { + + Context "Validate return types for Measure-Command" { + + It "Should return TimeSpan as the return type" { + (Measure-Command { Get-Date }).GetType() | Should Be timespan + } + } + + Context "Validate that it is executing commands correctly" { + + It "Should return TimeSpan after executing a script" { + (Measure-Command { echo hi }).GetType() | Should Be timespan + } + + It "Should return TimeSpan after executing a cmdlet" { + $pesterscript = "$here/assets/echoscript.ps1" + $testfile = "$here/assets/echoscript.ps1" + $testcommand = "echo pestertestscript" + $testcommand | Add-Content -Path $testfile + + (Measure-Command { $pesterscript }).GetType() | Should Be timespan + Remove-Item $testfile + } + } +}