From 2a8837aff736d1cc3d1dac1d48a10e307c4288ed Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 17:16:37 -0400 Subject: [PATCH] Add parameter tests --- Tests/Public/Invoke-ZertoFailover.Tests.ps1 | 60 ++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 index 50d2f9d..8582291 100644 --- a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 @@ -16,4 +16,62 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$($file.BaseName)::Parameter Unit Tests" { + it "has a mandatory string parameter for the vpgName" { + Get-Command $file.BaseName | Should -HaveParameter vpgName + Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string + Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + } + + it "has a non-mandatory string parameter for the checkpoint" { + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Type string + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Not -Mandatory + } + + it "has a non-mandatory string parameter for the commit policy" { + Get-Command $file.BaseName | Should -HaveParameter commitPolicy + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -DefaultValue "Rollback" + } + + it "has a non-mandatory int parameter for the shutdown policy" { + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Type int + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -DefaultValue 0 + } + + it "has a non-mandatory int parameter for the time to wait before force shutdown" { + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Type int + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600 + } + + it "has a non-mandatory bool parameter for the reverse protection policy" { + Get-Command $file.BaseName | Should -HaveParameter reverseProtection + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type bool + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Not -Mandatory + } + + it "has a non-mandatory array string parameter for the named VMs to be failed over" { + Get-Command $file.BaseName | Should -HaveParameter vmName + Get-Command $file.BaseName | Should -HaveParameter vmName -Type string[] + Get-Command $file.BaseName | Should -HaveParameter vmName -Not -Mandatory + } + + it "Supports 'SupportsShouldProcess'" { + Get-Command $file.BaseName | Should -HaveParameter WhatIf + Get-Command $file.BaseName | Should -HaveParameter Confirm + $file | Should -FileContentMatch 'SupportsShouldProcess' + $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +}