. $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 "Compare-StringToLocalMachineIdentifiers" { Context "Expected Matches" { $localIPAddresses = Get-NetIPAddress | Where-Object {$_.AddressFamily -eq "IPv4"} | Select-Object -ExpandProperty IPAddress $expectedMatches = @( "localhost", $env:COMPUTERNAME, "127.0.0.1", (Get-FullyQualifiedServerName), ($localIPAddresses | Select-Object -First 1) ) foreach ($goodString in $expectedMatches) { It "Returns true for $goodString" { Compare-StringToLocalMachineIdentifiers $goodString | Should -BeTrue } } } Context "Expected Failures" { $expectedFailures = @( "192.168.1.1", "FakeHostName.google.com", "@!@#!!!@(!()", 13984984521, -1 ) foreach ($badString in $expectedFailures) { It "Returns false for $badString" { Compare-StringToLocalMachineIdentifiers $badString | Should -BeFalse } } } Context "When a String is Piped To the Function" { It "Returns True if the String Matches" { "localhost" | Compare-StringToLocalMachineIdentifiers | Should -BeTrue } It "Returns False if the String Does Not Match" { "9.9.9.9" | Compare-StringToLocalMachineIdentifiers | Should -BeFalse } } }