Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime to struct. (#6006)

Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime class to struct and resolve the error in Set-Date cmdlet - SetLocalTime function is causing a parameter error (error code 0x00000057).
This commit is contained in:
Takuya Shibata 2018-01-25 12:54:27 +09:00 committed by Ilya
parent 874f5c1a85
commit f86371e347
2 changed files with 9 additions and 4 deletions

View file

@ -117,7 +117,7 @@ namespace Microsoft.PowerShell.Commands
internal static class NativeMethods
{
[StructLayout(LayoutKind.Sequential)]
public class SystemTime
public struct SystemTime
{
public UInt16 Year;
public UInt16 Month;

View file

@ -7,11 +7,16 @@ Describe "Set-Date" -Tag "CI" {
}
It "Set-Date should be able to set the date in an elevated context" -Skip:(! $IsElevated) {
{ get-date | set-date } | Should not throw
{ Get-Date | Set-Date } | Should Not Throw
}
It "Set-Date should be able to set the date with -Date parameter" -Skip:(! $IsElevated) {
$target = Get-Date
$expected = $target
Set-Date -Date $target | Should Be $expected
}
It "Set-Date should produce an error in a non-elevated context" -Skip:($IsElevated) {
{ get-date | set-date} | should throw
$Error[0].FullyQualifiedErrorId | should be "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
{ Get-Date | Set-Date } | ShouldBeErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
}
}