Merge pull request 267 from dev/get-date2 into develop

added test and renamed file
This commit is contained in:
Zach Folwick
2015-11-09 20:15:07 +00:00
2 changed files with 36 additions and 33 deletions
+36
View File
@@ -0,0 +1,36 @@
Describe "Get-Date" {
It "Should return a DateTime object upon being called" {
(Get-Date).GetType().Name.Equals('DateTime') | Should Be $true
}
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 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
}
It "Should check that Get-Date can return the correct datetime from the system time" {
$timeDifference = $(Get-Date).Subtract([System.DateTime]::Now)
$timeDifference.Days | Should Be 0
$timeDifference.Hours | Should Be 0
$timeDifference.Minutes | Should Be 0
$timeDifference.Milliseconds | Should BeLessThan 1
$timeDifference.Ticks | Should BeLessThan 10000
}
}
-33
View File
@@ -1,33 +0,0 @@
Describe "Get-Date" {
<#
1. foreach
2.
#>
It "Should return a DateTime object upon being called" {
(Get-Date).GetType().Name.Equals('DateTime') | Should Be $true
}
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 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
}
}