/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1
41 строка
2 KB
Travis Plunk
Add Windows ARM64 CI (#19040)
31 янв 2023, 23:06
Не верифицирован
31 янв 2023, 23:06
b2c4888
Код
Авторство
О чём код?
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. Import-Module HelpersCommon Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') { BeforeAll { [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("SetDate", $true) } AfterAll { [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("SetDate", $false) } It "Set-Date should be able to set the date in an elevated context" { { Get-Date | Set-Date } | Should -Not -Throw } # Check the individual properties as the types may be different It "Set-Date should be able to set the date with -Date parameter" { $target = Get-Date $expected = $target $observed = Set-Date -Date $target # do not test dayofweek because the number of the day is different between native and managed $observed.Day | Should -Be $expected.Day $observed.Hour | Should -Be $expected.Hour $observed.Minutes | Should -Be $expected.Minutes $observed.Month | Should -Be $expected.Month $observed.Second | Should -Be $expected.Second $observed.Year | Should -Be $expected.Year } } Describe "Set-Date" -Tag 'CI' { It "Set-Date should produce an error in a non-elevated context" { if (Test-IsElevated) { Set-ItResult -Skipped -Because "must NOT be run as admin" } { Get-Date | Set-Date } | Should -Throw -ErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand" } }