. $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-NewRelicNextLink" { Context "Has garbage input" { It "Throws on garbage input" { { (Get-NewRelicNextLink -LinkHeader "garbage input") } | Should -Throw } } Context "Has empty input" { $isEmpty = (Get-NewRelicNextLink -LinkHeader "") It "is empty" { $isEmpty | Should -BeNull } } Context "Has correct input" { # this test has no spaces between ; and rel - This is test case #1 for parsing the values $isRight = (Get-NewRelicNextLink -LinkHeader ';rel="first", ;rel="prev", ;rel="next", ;rel="last"') It "is the expected value" { $isRight | Should -Be "https://api.newrelic.com/v2/applications/5313884/metrics.xml?page=20" } } Context "Has correct input but the expected type is not present" { # this test has one space between ; and rel - This is test case #2 for parsing the values $isRight = (Get-NewRelicNextLink -LinkHeader '; rel="first", ; rel="prev", ; rel="next"' -LinkType 'last') It "is empty" { $isEmpty | Should -BeNull } } }