Chapters/final-exam/Step4.Tests.ps1

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"

Describe "Get-TMIPInfo" {

    # count number of interfaces and
    # addresses so we know what to expect
    $count = Get-NetAdapter | 
    Where Status -ne 'Disconnected' |
    ForEach { Get-NetIPAddress -InterfaceIndex $_.InterfaceIndex } |
    Measure |
    Select -Expand Count

    It "works against one computer" {
        $result = Get-TMIPInfo -ComputerName localhost 
        $result.count | should be $count
    }

    It "works against two computers" {
        $result = Get-TMIPInfo -ComputerName localhost,localhost
        $result.count | should be ($count * 2)
    }
}