Functions/Get-EmailAddressDomain.Tests.ps1
describe "BitTitan.Runbooks.Common/Get-EmailAddressDomain" -Tag "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Get-EmailAddressDomain.ps1" it -TestCases @( @{ emailAddress = "ValidEmail@domain.com" domain = "domain.com" }, @{ emailAddress = "valid.email@domain.com" domain = "domain.com" }, @{ emailAddress = "valid-email@domain.com" domain = "domain.com" }, @{ emailAddress = "valid-email@domain.com.sg" domain = "domain.com.sg" }, @{ emailAddress = "valid-email@domain.uni.edu.uk" domain = "domain.uni.edu.uk" } ) "extracts the domain '<domain>' from the valid email address '<emailAddress>'" { param ($emailAddress, $domain) Get-EmailAddressDomain $emailAddress | Should Be $domain } it -TestCases @( @{ emailAddress = "invalidEmail.com" }, @{ emailAddress = "invalidEmail." }, @{ emailAddress = "invalidEmail.c" } ) "returns null as the domain from the invalid email address '<emailAddress>'" { param ($emailAddress) Get-EmailAddressDomain $emailAddress | Should Be $null } } |