Update Method to Grab Path

https://jakubjares.com/2020/04/11/pester5-importing-ps-files/
This commit is contained in:
Wes Carroll
2020-04-20 16:35:02 -04:00
parent 71610ce9fe
commit 6620246e4c
107 changed files with 273 additions and 273 deletions
+13 -13
View File
@@ -1,45 +1,45 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
$global:here = (Split-Path -Parent $PSCommandPath)
$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0]
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
InModuleScope -ModuleName ZertoApiWrapper {
Context "$global:function::Parameter Unit Tests" {
it "have a mandatory parameter for the Input Object" {
It "have a mandatory parameter for the Input Object" {
Get-Command $global:function | Should -HaveParameter InputObject -Mandatory -Type PSCustomObject
}
it "Input Object should not accecpt a Null or Empty value" {
It "Input Object should not accecpt a Null or Empty value" {
$myObj = [PSCustomObject]@{ }
{ Get-Map -InputObject $myObj -Key "Key" -Value "Value" } | Should Throw
{ Get-Map -InputObject $null -Key "Key" -Value "Value" } | Should Throw
{ Get-Map -InputObject "" -Key "Key" -Value "Value" } | Should Throw
}
it "have a mandatory string parameter for the Map Key" {
It "have a mandatory string parameter for the Map Key" {
Get-Command $global:function | Should -HaveParameter Key -Mandatory -Type String
}
it "The Map variable should not accecpt a Null or Empty value" {
It "The Map variable should not accecpt a Null or Empty value" {
$myObj = [PSCustomObject]@{one = 1; two = 2 }
{ Get-Map -InputObject $myObj -Key "" -Value "Value" } | Should Throw
{ Get-Map -InputObject $null -Key $null -Value "Value" } | Should Throw
{ Get-Map -InputObject $myObj -Key 1 -Value "Value" } | Should Throw
}
it "The Value variable should not accecpt a Null or Empty value" {
It "The Value variable should not accecpt a Null or Empty value" {
$myObj = [PSCustomObject]@{one = 1; two = 2 }
{ Get-Map -InputObject $myObj -Key "Key" -Value "" } | Should Throw
{ Get-Map -InputObject $myObj -Key "Key" -Value $null } | Should Throw
{ Get-Map -InputObject $myObj -Key "Key" -Value 1 } | Should Throw
}
it "have a mandatory string parameter for the Map Value" {
It "have a mandatory string parameter for the Map Value" {
Get-Command $global:function | Should -HaveParameter Value -Mandatory -Type String
}
it "should have an Output type of Hashtable" {
It "should have an Output type of Hashtable" {
(Get-Command $global:function).OutputType.Name | Should -Match "Hashtable"
}
}
@@ -49,15 +49,15 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
BeforeEach {
$MyMap = Get-Map -InputObject $MyObj -Key "vmIdentifier" -Value "vmName"
}
it "Returned object should be a hashtable" {
It "Returned object should be a hashtable" {
$myMap | Should -BeOfType Hashtable
}
it "should return a hashtable with 3 entries" {
$myMap.count | should -Be 3
It "should return a hashtable with 3 entries" {
$myMap.count | Should -Be 3
}
it "should be properly mapped" {
It "should be properly mapped" {
$myMap["vmid.12"] | Should -Be "ExchangeMailbox"
$myMap["vmid.13"] | Should -Be "ExchangeApplication"
$myMap["vmid.14"] | Should -Be "ExchangeWeb"
+10 -10
View File
@@ -1,6 +1,6 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
$global:here = (Split-Path -Parent $PSCommandPath)
$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0]
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
@@ -16,7 +16,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
{ Get-ZertoApiFilter -filtertable $null } | Should Throw
}
it "should have an Output type of String" {
It "should have an Output type of String" {
(Get-Command $global:function).OutputType.Name | Should -Match "String"
}
}
@@ -47,19 +47,19 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
}
}
it "converts bool to text" {
Get-ZertoApiFilter -filtertable $singleBoolItemTest | should -Be "?BoolItem=True"
It "converts bool to text" {
Get-ZertoApiFilter -filtertable $singleBoolItemTest | Should -Be "?BoolItem=True"
}
it "one item test" {
Get-ZertoApiFilter -filtertable $oneItemTest | should -Be "?OneItem=Test"
It "one item test" {
Get-ZertoApiFilter -filtertable $oneItemTest | Should -Be "?OneItem=Test"
}
it "should ignore CommonParameters" {
Get-ZertoApiFilter -filtertable $commonParamTest | should -Be "?OneItem=Test"
It "should ignore CommonParameters" {
Get-ZertoApiFilter -filtertable $commonParamTest | Should -Be "?OneItem=Test"
}
it "should process a filter table with more than one item" {
It "should process a filter table with more than one item" {
$returnString = Get-ZertoApiFilter -filtertable $twoItemTest
$returnString | Should -match "^\?"
$returnString | Should -match "&"