Tests/Public/Support/Helper/Get-ISO3166Country.Tests.ps1
# Module: TeamsFunctions # Function: Test # Author: David Eberhardt # Updated: 23-JUL-2022 InModuleScope TeamsFunctions { BeforeAll { # } Describe -Tags ('Unit', 'Acceptance') "Function 'Get-ISO3166Country'" { Context 'Execution without Arguments' { BeforeAll { $Countries = Get-ISO3166Country } It 'Should return an array if called without parameters' { $Countries.Count | Should -BeGreaterThan 240 } It 'Should return objects of the Type TFCountry' { $Countries[0] | Should -BeOfType [System.Object] # TFCountry does not work :( } } Context 'Execution with Parameters' { It 'Should return one object when searched with -TwoLetterCode' { $QueryTwoLetterCode = Get-ISO3166Country -TwoLetterCode DK $QueryTwoLetterCode.Name | Should -Be 'Denmark' $QueryTwoLetterCode.ThreeLetterCode | Should -Be 'DNK' $QueryTwoLetterCode.NumericCode | Should -Be '208' $QueryTwoLetterCode.DialCode | Should -Be '45' $QueryTwoLetterCode.Region | Should -Be 'EMEA' $QueryTwoLetterCode.TimeZone | Should -Be 'UTC+01:00' } It 'Should return one object when searched with ThreeLetterCode' { $QueryThreeLetterCode = Get-ISO3166Country -ThreeLetterCode NOR $QueryThreeLetterCode.Name | Should -Be 'Norway' $QueryThreeLetterCode.TwoLetterCode | Should -Be 'NO' $QueryThreeLetterCode.NumericCode | Should -Be '578' $QueryThreeLetterCode.DialCode | Should -Be '47' $QueryThreeLetterCode.Region | Should -Be 'EMEA' $QueryThreeLetterCode.TimeZone | Should -Be 'UTC+01:00' } It 'Should return one object when searched with NumericCode' { $QueryNumericCode = Get-ISO3166Country -NumericCode 800 $QueryNumericCode.Name | Should -Be 'Uganda' $QueryNumericCode.TwoLetterCode | Should -Be 'UG' $QueryNumericCode.ThreeLetterCode | Should -Be 'UGA' $QueryNumericCode.DialCode | Should -Be '256' $QueryNumericCode.Region | Should -Be 'EMEA' $QueryNumericCode.TimeZone | Should -Be 'UTC+03:00' } It 'Should return an array when searched with Region' { $QueryRegion = Get-ISO3166Country -Region APAC $QueryRegion.Count | Should -BeGreaterThan 5 } It 'Should return an array when searched with TimeZone' { $QueryTimeZone = Get-ISO3166Country -TimeZone UTC-11:00 $QueryTimeZone.Count | Should -Be 3 } It 'Should return a single country when searched with DialCode' { $QueryTimeZone = Get-ISO3166Country -DialCode 43 $QueryTimeZone.Count | Should -Be 1 $QueryTimeZone.Name | Should -Be 'Austria' } } } } |