. $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-AwsSettings" { Context "When Called" { Mock -ModuleName $moduleForMock Invoke-Command { $returnSettings = @{ "Region" = "mordor-west-1" } return $returnSettings } Mock -ModuleName $moduleForMock Write-Host {} $profileName = "unitTestProfile" $serverName = "myFakeServer" It "Returns Settings Object"{ $settings = Get-AwsSettings -ServerToTest $serverName -ProfileName $profileName Assert-MockCalled -ModuleName $moduleForMock Invoke-Command $settings | Should -Not -Be $null } It "Returns Region"{ $settings = Get-AwsSettings -ServerToTest $serverName -ProfileName $profileName Assert-MockCalled -ModuleName $moduleForMock Invoke-Command $settings.Region | Should -Be "mordor-west-1" } It "Returns ProfileName"{ $settings = Get-AwsSettings -ServerToTest $serverName -ProfileName $profileName Assert-MockCalled -ModuleName $moduleForMock Invoke-Command $settings.Profile | Should -Be $profileName } } }