Correct Get-TimestampFromFile to actually return DateTime

This commit is contained in:
Daniel Scott-Raynsford
2019-01-19 15:52:16 +11:00
parent 1f4888dd6e
commit cf681adc2e
3 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -1042,7 +1042,7 @@ function Get-TimestampFromFile
$Timestamp
)
return $File.$Timestamp.DateTime
return $File.$Timestamp
}
<#
+3 -2
View File
@@ -583,8 +583,9 @@ The following parameters will be the same for each process in the set:
* Update integration tests to meet Pester 4.0.0 standards.
* Update end-to-end tests to meet Pester 4.0.0 standards.
* Update unit and integration tests to meet Pester 4.0.0 standards.
* Wrapped all verbose message parameters with quotes to make identifying
actual paths possible.
* Wrapped all path and identifier strings in verbose messages with
quotes to make it easier to identify the limit of the string when
debugging.
* Refactored date/time checksum code to improve testability and ensure
tests can run on machines with localized datetime formats that are not
US.
+6 -8
View File
@@ -2095,10 +2095,8 @@ Describe 'Archive Unit Tests' {
Describe 'Get-ChecksumFromFileTimestamp' {
$testFileInfo = New-Object -TypeName 'System.IO.FileInfo' -ArgumentList @( $PSScriptRoot )
$testFileCreationTime = $testFileInfo.CreationTime.DateTime
$testFileLastWriteTime = $testFileInfo.LastWriteTime.DateTime
$testFileCreationTimeChecksum = (Get-Date -Date $testFileCreationTime -Format 'G')
$testFileLastWriteTimeChecksum = (Get-Date -Date $testFileLastWriteTime -Format 'G')
$testFileCreationTimeChecksum = (Get-Date -Date $testFileInfo.CreationTime -Format 'G')
$testFileLastWriteTimeChecksum = (Get-Date -Date $testFileInfo.LastWriteTime -Format 'G')
Context 'When checksum specified as CreatedDate' {
$getChecksumFromFileTimestampParameters = @{
@@ -2145,7 +2143,7 @@ Describe 'Archive Unit Tests' {
}
It 'Should return the creation time of the file as a Checksum' {
Get-TimestampForChecksum @getTimestampForChecksumParameters | Should -Be $testFileInfo.CreationTime.DateTime
Get-TimestampForChecksum @getTimestampForChecksumParameters | Should -Be $testFileInfo.CreationTime
}
}
@@ -2160,7 +2158,7 @@ Describe 'Archive Unit Tests' {
}
It 'Should return the last write time of the file' {
Get-TimestampForChecksum @getTimestampForChecksumParameters | Should -Be $testFileInfo.LastWriteTime.DateTime
Get-TimestampForChecksum @getTimestampForChecksumParameters | Should -Be $testFileInfo.LastWriteTime
}
}
}
@@ -2179,7 +2177,7 @@ Describe 'Archive Unit Tests' {
}
It 'Should return the creation time of the file as a Checksum' {
Get-TimestampFromFile @getTimestampFromFileParameters | Should -Be $testFileInfo.CreationTime.DateTime
Get-TimestampFromFile @getTimestampFromFileParameters | Should -Be $testFileInfo.CreationTime
}
}
@@ -2194,7 +2192,7 @@ Describe 'Archive Unit Tests' {
}
It 'Should return the creation time of the file as a Checksum' {
Get-TimestampFromFile @getTimestampFromFileParameters | Should -Be $testFileInfo.LastWriteTime.DateTime
Get-TimestampFromFile @getTimestampFromFileParameters | Should -Be $testFileInfo.LastWriteTime
}
}
}