Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Created March 19, 2017 09:03
Show Gist options
  • Save nohwnd/c57e9e67c530a656d2faae73a651cd8c to your computer and use it in GitHub Desktop.
Save nohwnd/c57e9e67c530a656d2faae73a651cd8c to your computer and use it in GitHub Desktop.
Why Pester tests example
# author Dave Wyatt, I just copied the code from here https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/14/what-is-pester-and-why-should-i-care/
function TimesTwo ($value) {
return $value * 2
}
Describe 'TimesTwo' {
Context 'Numbers' {
It 'Multiplies numbers properly' {
TimesTwo 2 | Should Be 4
}
}
Context 'Strings' {
It 'Multiplies strings properly' {
TimesTwo 'Test' | Should BeExactly 'TestTest'
}
}
Context 'Arrays' {
It 'Multiplies arrays properly' {
$array = 1..2
$result = TimesTwo $array
$result.Count | Should Be 4
$result[0] | Should Be 1
$result[1] | Should Be 2
$result[2] | Should Be 1
$result[3] | Should Be 2
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment