Last active
November 10, 2015 23:51
-
-
Save Nora-Ballard/a680b3bb1e1802b395ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string]$VMNameStr) | |
@($VMNameStr.Split(',').Trim()) | Where {$_ -ne ''} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") | |
$Script = "$here\$sut" | |
Describe "Nov2015ScriptGames" { | |
Context "When the string is ',' deliminated" { | |
$TestString = 'COMPUTER1,COMPUTER2,, COMPUTER3 , COMPUTER 4, COMPUTER5' | |
$ActualOutput = & $Script -VMNameStr $TestString | |
It "Does not return null names" { | |
$ActualOutput | Should Not Be $null | |
} | |
It "Returns the individual VM Names without leading/trailing whitespace" { | |
$ActualOutput.Count | Should Be 5 | |
$ActualOutput[0] | Should Be 'COMPUTER1' | |
$ActualOutput[1] | Should Be 'COMPUTER2' | |
$ActualOutput[2] | Should Be 'COMPUTER3' | |
$ActualOutput[3] | Should Be 'COMPUTER 4' | |
$ActualOutput[4] | Should Be 'COMPUTER5' | |
} | |
} | |
Context "When the String does not contain a ','" { | |
$TestString = 'COMPUTER1' | |
It "Returns the string given" { | |
$ActualOutput = & $Script -VMNameStr $TestString | |
$ActualOutput | Should Be $TestString | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment