<# .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152 Created on: 5/22/2018 4:48 PM Created by: Ben Claussen Organization: NEOnet Filename: DCIM.Tests.ps1 =========================================================================== .DESCRIPTION DCIM tests. #> Import-Module Pester Remove-Module NetboxPS -Force -ErrorAction SilentlyContinue $ModulePath = "$PSScriptRoot\..\dist\NetboxPS.psd1" if (Test-Path $ModulePath) { Import-Module $ModulePath -ErrorAction Stop } Describe -Name "DCIM Tests" -Tag 'DCIM' -Fixture { Mock -CommandName 'CheckNetboxIsConnected' -Verifiable -ModuleName 'NetboxPS' -MockWith { return $true } Mock -CommandName 'Invoke-RestMethod' -Verifiable -ModuleName 'NetboxPS' -MockWith { # Return a hashtable of the items we would normally pass to Invoke-RestMethod return [ordered]@{ 'Method' = $Method 'Uri' = $Uri 'Headers' = $Headers 'Timeout' = $Timeout 'ContentType' = $ContentType 'Body' = $Body } } Mock -CommandName 'Get-NetboxCredential' -Verifiable -ModuleName 'NetboxPS' -MockWith { return [PSCredential]::new('notapplicable', (ConvertTo-SecureString -String "faketoken" -AsPlainText -Force)) } Mock -CommandName 'Get-NetboxHostname' -Verifiable -ModuleName 'NetboxPS' -MockWith { return 'netbox.domain.com' } InModuleScope -ModuleName 'NetboxPS' -ScriptBlock { $script:NetboxConfig.Choices.DCIM = (Get-Content "$PSScriptRoot\DCIMChoices.json" -ErrorAction Stop | ConvertFrom-Json) } }