fixed get-date tests

This commit is contained in:
Zachary Folwick 2015-07-16 14:59:50 -07:00
parent c55e5cbc88
commit 9493af81af

View file

@ -10,14 +10,28 @@ Describe "Test-Get-Date" {
It "Should return a DateTime object upon being called" {
(Get-Date).GetType().Name.Equals('DateTime') | Should Be $true
}
It "Should filter properly when displayhint switch is used" {
(Get-Date -DisplayHint Time).ToString().Contains(":") |Should be $true
(Get-Date -DisplayHint Date).ToString().Contains(":") | Should be $false
It "Should have colons when ToString method is used" {
(Get-Date).ToString().Contains(":") | Should be $true
(Get-Date -DisplayHint Time).ToString().Contains(":") | Should be $true
(Get-Date -DisplayHint Date).ToString().Contains(":") | Should be $true
}
It "Should be able to pipe the output to another cmdlet" {
$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "."}
$timestamp.ToString().Contains(":") | Should be $false
It "Should be able to use the format flag" {
# You would think that one could use simple loops here, but apparently powershell in windows returns different values in loops
(Get-Date -Format d).Contains("/") | Should be $true
(Get-Date -Format D).Contains(",") | Should be $true
(Get-Date -Format f).Contains(",") -and (Get-Date -Format f).Contains(":") | Should be $true
(Get-Date -Format F).Contains(",") -and (Get-Date -Format F).Contains(":") | Should be $true
(Get-Date -Format g).Contains("/") -and (Get-Date -Format g).Contains(":") | Should be $true
(Get-Date -Format G).Contains("/") -and (Get-Date -Format G).Contains(":") | Should be $true
(Get-Date -Format m).Contains(",") -or `
(Get-Date -Format m).Contains(":") -or `
(Get-Date -Format m).Contains("/") | Should be $false
}
}
}