Respect -Repeat/-MtuSize/-Traceroute:$false in Test-Connection (#26479)

This commit is contained in:
yotsuda
2025-11-21 17:12:28 +05:00
committed by GitHub
parent 108eb857bb
commit fb6403d4da
2 changed files with 51 additions and 22 deletions
@@ -258,6 +258,15 @@ Describe "Test-Connection" -tags "CI", "RequireSudoOnUnix" {
$pingResults.Where( { $_.Status -eq 'Success' }, 'Default', 1 ).BufferSize | Should -Be 32
}
}
It "Repeat with explicit false should behave like default ping" {
# -Repeat:$false should behave the same as not specifying -Repeat
$pingResults = Test-Connection $targetAddress -Repeat:$false
# Should get exactly 4 pings (the default Count value)
$pingResults.Count | Should -Be 4
$pingResults[0].Address | Should -BeExactly $targetAddress
}
}
Context "MTUSizeDetect" {
@@ -291,6 +300,16 @@ Describe "Test-Connection" -tags "CI", "RequireSudoOnUnix" {
$result | Should -BeOfType Int32
$result | Should -BeGreaterThan 0
}
It "MtuSize with explicit false should behave like default ping" {
# -MtuSize:$false should behave the same as not specifying -MtuSize (default ping)
$pingResults = Test-Connection $targetAddress -MtuSize:$false
# Should return PingStatus, not PingMtuStatus
$pingResults[0] | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus
# Should get 4 pings (the default Count value)
$pingResults.Count | Should -Be 4
}
}
Context "TraceRoute" {
@@ -332,6 +351,16 @@ Describe "Test-Connection" -tags "CI", "RequireSudoOnUnix" {
$results.Hostname | Should -Not -BeNullOrEmpty
}
It "Traceroute with explicit false should behave like default ping" {
# -Traceroute:$false should behave the same as not specifying -Traceroute (default ping)
$pingResults = Test-Connection $targetAddress -Traceroute:$false
# Should return PingStatus, not TraceStatus
$pingResults[0] | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus
# Should get 4 pings (the default Count value)
$pingResults.Count | Should -Be 4
}
}
}