Tests/Test-IsValidIPAddress.Tests.ps1

Try
{
    Import-Module -Name Pester -MinimumVersion '5.0.0' -Force
}
Catch
{
    Try
    {
         $module = Get-Module -Name Pester;
         $modulePath = Split-Path $module.Path;
         $psdPath = "{0}\{1}" -f $modulePath, "Pester.psd1"
         Import-Module $psdPath -ErrorAction Stop
    }
    Catch
    {
        Throw "DirectoryServices PS module could not be loaded. $($_.Exception.Message)"
    }
}
   
   

Describe 'Test-IsValidIPAddress' {
    
    Context "Network configuration" {
        [IPAddress]$IP = 10.0.0.1
        
        It "Should have an '.'" {
            Test-IsValidIPAddress -IP $IP | Should -BeLike '.'
        }
        
        It "Should be of type [ipaddress]" {
            Test-IsValidIPAddress -IP $IP | Should -BeOfType [ipaddress]
        }
    }
}