/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Uptime.Tests.ps1
43 строки
2 KB
Jonathan Gilbert
Correct handling of explicit -Since:$false parameter value in Get-Uptime (#26141)
09 окт 2025, 13:48
Не верифицирован
09 окт 2025, 13:48
e562d3f
Код
Авторство
О чём код?
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. Describe "Get-Uptime" -Tags "CI" { BeforeAll { $IsHighResolution = [system.diagnostics.stopwatch]::IsHighResolution # Skip Get-Uptime test if IsHighResolution = false # because stopwatch.GetTimestamp() return DateTime.UtcNow.Ticks # instead of ticks from system startup if ( ! $IsHighResolution ) { $origDefaults = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues['it:skip'] = $true } } AfterAll { if ( ! $IsHighResolution ){ $global:PSDefaultParameterValues = $origDefaults } } It "Get-Uptime return timespan (default -Timespan)" { $upt = Get-Uptime $upt | Should -BeOfType Timespan } It "Get-Uptime -Since return DateTime" { $upt = Get-Uptime -Since $upt | Should -BeOfType DateTime } It "Get-Uptime -Since:`$false return TimeSpan" { $upt = Get-Uptime -Since:$false $upt | Should -BeOfType TimeSpan } It "Get-Uptime throw if IsHighResolution == false" { # Enable the test hook [system.management.automation.internal.internaltesthooks]::SetTestHook('StopwatchIsNotHighResolution', $true) try { { Get-Uptime } | Should -Throw -ErrorId "GetUptimePlatformIsNotSupported,Microsoft.PowerShell.Commands.GetUptimeCommand" } finally { # Disable the test hook [system.management.automation.internal.internaltesthooks]::SetTestHook('StopwatchIsHighResolutionIsFalse', $false) } } }