Skip to content

Commit

Permalink
Test initial check in
Browse files Browse the repository at this point in the history
  • Loading branch information
roberttoups committed Nov 10, 2023
1 parent 27fb65e commit 33889fb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Tests/ConvertTo-IPv4.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$ModuleName = 'IPv4Toolbox'
$script:FunctionName = 'ConvertTo-IPv4'
$ParentPath = Split-Path -Path $PSScriptRoot -Parent
$ModulePath = Join-Path -Path $ParentPath -ChildPath "$($ModuleName).psm1"
Get-Module -Name $ModuleName |
Remove-Module -Force
Import-Module $ModulePath -Force

InModuleScope $ModuleName {
Describe 'ConvertTo-IPv4 Tests' {
Context "Basic function unit tests for $FunctionName" -Tags @('Build', 'Unit') {
It 'Converts 3232235777 to the correct IPv4 representation' {
$Integer = 3232235777
$Result = ConvertTo-IPv4 -Integer $Integer
$ExpectedResult = '192.168.1.1'
$Result | Should -Be $ExpectedResult
}

It 'Converts 2130706433 to the correct IPv4 representation' {
$Integer = 2130706433
$Result = ConvertTo-IPv4 -Integer $Integer
$ExpectedResult = '127.0.0.1'
$Result | Should -Be $ExpectedResult
}

It 'Converts 4294967295 to the correct IPv4 representation' {
$Integer = 4294967295
$Result = ConvertTo-IPv4 -Integer $Integer
$ExpectedResult = '255.255.255.255'
$Result | Should -Be $ExpectedResult
}

It 'throws an error for invalid input type' {
{ ConvertTo-IPv4 -Integer 'NotAnInteger' } | Should -Throw -ExpectedMessage '*Cannot process argument transformation on parameter ''Integer''. Cannot convert value "NotAnInteger" to type "System.Int64". Error: "The input string ''NotAnInteger'' was not in a correct format."*'
}
}
}
}

0 comments on commit 33889fb

Please sign in to comment.