Wraped all the tests inModuleScope for invoke-pester invocation.

Moved function name into module scope.
This commit is contained in:
Conor Tolan
2019-02-23 18:56:44 +00:00
parent b90c83ac56
commit 5c833d4ce5
5 changed files with 264 additions and 252 deletions

View File

@@ -1,6 +1,8 @@
#Requires -Modules Pester, VMware.VMC
$functionName = $MyInvocation.MyCommand.Name.TrimEnd(".Tests.ps1")
Describe "$functionName" -Tag 'Unit' {
inModuleScope VMware.VMC {
$functionName = "Connect-VMCVIServer"
Describe "$functionName" -Tag 'Unit' {
. "$PSScriptRoot/Shared.ps1"
$Org = 'MyOrg'
@@ -56,4 +58,5 @@ Describe "$functionName" -Tag 'Unit' {
-and $Password -eq $Mockedcreds.password }
}
}
}
}

View File

@@ -1,7 +1,9 @@
#Requires -Modules Pester, VMware.VMC, VMware.VimAutomation.Vmc
$functionName = $MyInvocation.MyCommand.Name.TrimEnd(".Tests.ps1")
Describe "$functionName" -Tag 'Unit' {
inModuleScope VMware.VMC {
$functionName = "Get-VMCCommand"
Describe "$functionName" -Tag 'Unit' {
Mock Get-Command {
"Mocked Command Response"
}
@@ -17,4 +19,5 @@ Describe "$functionName" -Tag 'Unit' {
Assert-MockCalled -CommandName Get-command -Times 1 -Scope It -ParameterFilter { $Module -eq 'VMware.VMC' }
}
}
}
}

View File

@@ -1,8 +1,9 @@
#Requires -Modules Pester, VMware.VMC
$functionName = $MyInvocation.MyCommand.Name.TrimEnd(".Tests.ps1")
Import-Module -Name VMware.VimAutomation.Cis.Core
Describe "$functionName" -Tag 'Unit' {
inModuleScope VMware.VMC {
$functionName = "Get-VMCOrg"
Describe "$functionName" -Tag 'Unit' {
. "$PSScriptRoot/Shared.ps1"
$global:DefaultVMCServers = $true
@@ -70,4 +71,5 @@ Describe "$functionName" -Tag 'Unit' {
$(Get-VMCOrg -name $OrgName)[1].id | Should -be $id
}
}
}
}

View File

@@ -1,8 +1,9 @@
#Requires -Modules Pester, VMware.VMC
$functionName = $MyInvocation.MyCommand.Name.TrimEnd(".Tests.ps1")
Import-Module -Name VMware.VimAutomation.Cis.Core
Describe "$functionName" -Tag 'Unit' {
inModuleScope VMware.VMC {
$functionName ="Get-VmcSddc"
Describe "$functionName" -Tag 'Unit' {
. "$PSScriptRoot/Shared.ps1"
$global:DefaultVMCServers = $true
@@ -77,4 +78,5 @@ Describe "$functionName" -Tag 'Unit' {
$(Get-VMCSDDC -Org $OrgId -name $name).name | Should -be $name
}
}
}
}

View File

@@ -1,8 +1,9 @@
#Requires -Modules Pester, VMware.VMC
$functionName = $MyInvocation.MyCommand.Name.TrimEnd(".Tests.ps1")
Import-Module -Name VMware.VimAutomation.Cis.Core
Describe "$functionName" -Tag 'Unit' {
inModuleScope VMware.VMC {
$functionName = "Get-VMCTask"
Describe "$functionName" -Tag 'Unit' {
. "$PSScriptRoot/Shared.ps1"
$global:DefaultVMCServers = $true
@@ -75,4 +76,5 @@ Describe "$functionName" -Tag 'Unit' {
$(Get-VMCTask -Org $OrgId)[1].name | Should -be $Notname
}
}
}
}