From bc0bb337a6d383c27a3fc9fcbe714ac53ca86366 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 17:37:18 -0400 Subject: [PATCH] Add null or empty assertions --- Tests/Public/Export-ZertoVpg.Tests.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index 308f909..2b0e2de 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -1,4 +1,5 @@ #Requires -Modules Pester +#Region - Test Setup $moduleFileName = "ZertoApiWrapper.psd1" $here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") @@ -7,6 +8,7 @@ $modulePath = $here -replace "Public", "" $moduleFile = Get-ChildItem "$modulePath\$moduleFileName" Get-Module -Name ZertoApiWrapper | Remove-Module -Force Import-Module $moduleFile -Force +#EndRegion Describe $file.BaseName -Tag 'Unit' { @@ -18,7 +20,7 @@ Describe $file.BaseName -Tag 'Unit' { } it "has a mantatory string parameter for the output path" { - Get-Command $file.BaseName | Should -HaveParameter outputPath -Mandatory -Type String + Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory } it "has a non-mandatory string array parameter for vpgName(s) to export" { @@ -32,4 +34,14 @@ Describe $file.BaseName -Tag 'Unit' { it "No defined vpgName or AllVpg switch should throw an error" { {Export-ZertoVpg -outputPath "."} | Should -Throw } -} \ No newline at end of file + + it "Output path does not take null or empty string" { + {Export-ZertoVpg -outputPath "" -allVpgs} | Should -Throw + {Export-ZertoVpg -outputPath $null -allVpgs} | Should -Throw + } + + it "Vpg Name parameter does not take null or empty string" { + {Export-ZertoVpg -outputPath "." -vpgName = ""} | Should -Throw + {Export-ZertoVpg -outputPath "." -vpgName = $null} | Should -Throw + } +}