Skip to content

Instantly share code, notes, and snippets.

@Nora-Ballard
Last active November 10, 2015 23:51
Show Gist options
  • Save Nora-Ballard/a680b3bb1e1802b395ba to your computer and use it in GitHub Desktop.
Save Nora-Ballard/a680b3bb1e1802b395ba to your computer and use it in GitHub Desktop.
param([string]$VMNameStr)
@($VMNameStr.Split(',').Trim()) | Where {$_ -ne ''}
$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