Files
PowerShell-PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1
T
Klaudia Algiz 2df9aac811 Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests (#6682)
Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests.
Get rid of try { } catch { } formula to assert that errors were thrown.
Small fixes in tests to obey the new Pester -Parameter syntax.
2018-05-17 14:42:04 -07:00

20 lines
760 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 } | Should -Throw -ErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
}
}