Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Start-Sleep.Tests.ps1
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

43 lines
1.5 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Start-Sleep DRT Unit Tests" -Tags "CI" {
# WaitHandle.WaitOne(milliseconds, exitContext) is not accurate.
# The wait time varies from 980ms to 1020ms from observation, so
# the tests here are changed to be greater than 950ms.
It "Should work properly when sleeping with Second" {
$watch = [System.Diagnostics.Stopwatch]::StartNew()
Start-Sleep -Seconds 1
$watch.Stop()
$watch.ElapsedMilliseconds | Should BeGreaterThan 950
$watch.ElapsedMilliseconds | Should BeLessThan 1100
}
It "Should work properly when sleeping with Milliseconds" {
$watch = [System.Diagnostics.Stopwatch]::StartNew()
Start-Sleep -Milliseconds 1000
$watch.Stop()
$watch.ElapsedMilliseconds | Should BeGreaterThan 950
$watch.ElapsedMilliseconds | Should BeLessThan 1100
}
It "Should work properly when sleeping with ms alias" {
$watch = [System.Diagnostics.Stopwatch]::StartNew()
Start-Sleep -ms 1000
$watch.Stop()
$watch.ElapsedMilliseconds | Should BeGreaterThan 950
$watch.ElapsedMilliseconds | Should BeLessThan 1100
}
}
Describe "Start-Sleep" -Tags "CI" {
Context "Validate Start-Sleep works properly" {
It "Should only sleep for at least 1 second" {
$result = Measure-Command { Start-Sleep -s 1 }
$result.TotalSeconds | Should BeGreaterThan 0.25
}
}
}