From 6c578f7b78899453bc1b5b62875d4f406cbae22d Mon Sep 17 00:00:00 2001 From: Conor Tolan Date: Sat, 23 Feb 2019 16:37:03 +0000 Subject: [PATCH] Added mock write-host to clean up output. Added the general creation of the $object needed to mock the function. --- Pester/Functions/Connect-VMCVIServer.tests.ps1 | 2 ++ Pester/Functions/Get-VMCOrg.tests.1.ps1 | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Pester/Functions/Connect-VMCVIServer.tests.ps1 b/Pester/Functions/Connect-VMCVIServer.tests.ps1 index 4a7feec..2448ab3 100644 --- a/Pester/Functions/Connect-VMCVIServer.tests.ps1 +++ b/Pester/Functions/Connect-VMCVIServer.tests.ps1 @@ -22,6 +22,8 @@ Describe "$functionName" -Tag 'Unit' { return $object } + Mock Write-host {} + Mock Connect-VIServer {} Mock Connect-CisServer {} diff --git a/Pester/Functions/Get-VMCOrg.tests.1.ps1 b/Pester/Functions/Get-VMCOrg.tests.1.ps1 index 19d79fc..6f451aa 100644 --- a/Pester/Functions/Get-VMCOrg.tests.1.ps1 +++ b/Pester/Functions/Get-VMCOrg.tests.1.ps1 @@ -21,8 +21,9 @@ Describe "$functionName" -Tag 'Unit' { "user_name" = $user_name "id" = $id } - #$object | Add-Member -MemberType ScriptMethod -Name "list" -Value { $MockedList } + $object = [PSCustomObject]@{} + $object | Add-Member -MemberType ScriptMethod -Name "list" -Value { $MockedList } $MockedArray = @() $MockedArray += $MockedList @@ -37,6 +38,7 @@ Describe "$functionName" -Tag 'Unit' { } Context "Behavior testing" { + It "calls get-service to com.vmware.vmc.orgs" { { Get-VMCOrg -name $OrgName } | Should Not Throw Assert-MockCalled -CommandName Get-VMCService -Times 1 -Scope It -ParameterFilter { $name -eq $Service }