Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1
T

20 lines
753 B
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
It "Set-Date should be able to set the date in an elevated context" {
{ Get-Date | Set-Date } | Should -Not -Throw
}
It "Set-Date should be able to set the date with -Date parameter" {
$target = Get-Date
$expected = $target
Set-Date -Date $target | Should -Be $expected
}
}
Describe "Set-Date" -Tag 'CI' {
It "Set-Date should produce an error in a non-elevated context" {
{ Get-Date | Set-Date } | ShouldBeErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
}
}