From 94147e2b59c4bfd2c65085d9ddaca329bea0587f Mon Sep 17 00:00:00 2001 From: Mariah Breakey Date: Thu, 13 Apr 2017 12:58:23 -0700 Subject: [PATCH] fixing bug in Archive unit test --- Tests/Unit/MSFT_Archive.Tests.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/Unit/MSFT_Archive.Tests.ps1 b/Tests/Unit/MSFT_Archive.Tests.ps1 index e6805cb..001e6f6 100644 --- a/Tests/Unit/MSFT_Archive.Tests.ps1 +++ b/Tests/Unit/MSFT_Archive.Tests.ps1 @@ -2095,12 +2095,14 @@ Describe 'Archive Unit Tests' { } Describe 'Get-TimestampForChecksum' { - Mock -CommandName 'Get-Date' -MockWith { return $Date } + # This is the actual file info of this file since we cannot set the properties of mock objects $testFileInfo = New-Object -TypeName 'System.IO.FileInfo' -ArgumentList @( $PSScriptRoot ) - $testFileCreationTime = $testFileInfo.CreationTime.DateTime - $testFileLastWriteTime = $testFileInfo.LastWriteTime.DateTime + $testFileCreationTime = (Get-Date -Date $testFileInfo.CreationTime.DateTime -Format 'G') + $testFileLastWriteTime = (Get-Date -Date $testFileInfo.LastWriteTime.DateTime -Format 'G') + + Mock -CommandName 'Get-Date' -MockWith { return $testFileCreationTime } Context 'Checksum specified as CreatedDate' { $getTimestampForChecksumParameters = @{ @@ -2128,6 +2130,8 @@ Describe 'Archive Unit Tests' { } } + Mock -CommandName 'Get-Date' -MockWith { return $testFileLastWriteTime } + Context 'Checksum specified as ModifiedDate' { $getTimestampForChecksumParameters = @{ File = $testFileInfo