Create function and required supporting docs

Import-ZertoVmNicSetting
This commit is contained in:
Wes Carroll
2019-07-09 13:12:22 -04:00
parent cb991b3d0c
commit 4d7d1391ff
3 changed files with 224 additions and 0 deletions
@@ -0,0 +1,39 @@
#Requires -Modules Pester
$moduleFileName = "ZertoApiWrapper.psd1"
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
$file = Get-ChildItem "$here\$sut"
$modulePath = $here -replace "Public", ""
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
Import-Module $moduleFile -Force
Describe $file.BaseName -Tag 'Unit' {
It "is valid Powershell (Has no script errors)" {
$contents = Get-Content -Path $file -ErrorAction Stop
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
$errors | Should -HaveCount 0
}
Context "$($file.BaseName)::Parameter Unit Tests" {
It "Has a mandatory string array parameter for the settings file to import" {
Get-Command $file.BaseName | Should -HaveParameter InputFile
Get-Command $file.BaseName | Should -HaveParameter InputFile -Mandatory
Get-Command $file.BaseName | Should -HaveParameter InputFile -Type String
}
It "Will not accecpt a Null or Empty string for the settings file" {
{ Import-ZertoVpg -InputFile $null } | Should -Throw
{ Import-ZertoVpg -InputFile "" } | Should -Throw
{ Import-ZertoVpg -InputFile @() } | Should -Throw
}
}
Context "$($file.BaseName)::Function Unit Tests" {
}
}