. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" Describe "Get-AutomoxAgentPath" { Context "Validation" { It "Writes a Warning if No Executable Found" { Mock -ModuleName $moduleForMock Get-ChildItem { return $null } ( Get-AutomoxAgentPath 3>&1 ) -match "Unable to Locate the Automox Agent Executable" | Should -Be $true } It "Returns the FullName Property of the File When Found" { Mock -ModuleName $moduleForMock Get-ChildItem { return New-Object PSObject -Property @{ Name="Foo"; FullName="C:\Temp\FooBar\amagent.exe"; } } Get-AutomoxAgentPath | Should -Be "C:\Temp\FooBar\amagent.exe" } } }